~w96k/doujinhub

457e6c0b2e85127f463d0fcf8825abe98fa2e1c6 — Mikhail Kirillov 6 months ago 2a4b716 feature/base
Modify guix setup
M .gitignore => .gitignore +2 -1
@@ 1,1 1,2 @@
__pycache__
\ No newline at end of file
__pycache__
app/css/mini.css
\ No newline at end of file

A .guix-channel => .guix-channel +3 -0
@@ 0,0 1,3 @@
(channel
  (version 0)
  (directory "guix"))
\ No newline at end of file

A DEV.org => DEV.org +23 -0
@@ 0,0 1,23 @@
* Tech choice
** Background
   I'm user of guix system distribution and newbie python developer. I
   love LISPs a lot, but they (all) lack libraries for web, that's why
   programming language choice is Python for this project. If we will
   encoruage performance problems some parts can be rewritten at
   Common Lisp or Go.
** Guix
   Guix can create environments like pienv, but guix is not limited to
   python. It can be used for almost everything.
* What to implement
** TODO Guile script for virtual environment
   :LOGBOOK:
   CLOCK: [2020-02-02 Вс 23:11]--[2020-02-02 Вс 23:36] =>  0:25
   CLOCK: [2020-02-02 Вс 22:24]--[2020-02-02 Вс 22:49] =>  0:25
   CLOCK: [2020-02-02 Вс 21:54]--[2020-02-02 Вс 22:19] =>  0:25
   CLOCK: [2020-02-02 Вс 21:24]--[2020-02-02 Вс 21:49] =>  0:25
   :END:
** TODO Mini.css guix loading
** TODO Mini.css for styles
** TODO About page
** TODO Setup postgresql
** TODO Change license to AGPL since its a web service project

D app.py => app.py +0 -9
@@ 1,9 0,0 @@
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

A app/__init__.py => app/__init__.py +5 -0
@@ 0,0 1,5 @@
from flask import Flask

app = Flask(__name__)

from app import routes

A app/routes.py => app/routes.py +8 -0
@@ 0,0 1,8 @@
from flask import render_template
from app import app

@app.route('/')
@app.route('/index')
def index():
    user = {'username': 'Miguel'}
    return render_template('index.html', title='Home', user=user)

A app/templates/index.html => app/templates/index.html +8 -0
@@ 0,0 1,8 @@
<html>
  <head>
    <title>{{ title }} - Microblog</title>
  </head>
  <body>
    <h1>Hello, {{ user.username }}!</h1>
  </body>
</html>

D debug-env.sh => debug-env.sh +0 -1
@@ 1,1 0,0 @@
guix build -K --file=env.scm -v 2

M env.sh => env.sh +12 -1
@@ 1,4 1,15 @@
# Add mini.css to app/css/mini.css
# (Delete this after final guix packaging)
rm -r app/css/mini.css app/css/mini.css-link
guix build -K -L guix/ -v 2 -e "(@ (non-gnu packages mini-css) mini-css)" -r app/css/mini.css-link
cp -r app/css/mini.css-link/lib/node_modules/mini.css/src/mini/ app/css/mini.css
chmod -R +w app/css/mini.css/
chown -R $(whoami) app/css/mini.css/
rm app/css/mini.css-link

# Create virtual environment for a project
guix environment --container \
     --load=guix/doujinhub.scm \
     -L guix/ \
     -e "(@ (non-gnu packages doujinhub) doujinhub)" \
     --network \
     -v 2

A guix/non-gnu/packages/doujinhub.scm => guix/non-gnu/packages/doujinhub.scm +90 -0
@@ 0,0 1,90 @@
;;; Doujinhub --- Web-service for a collaboration between composers,
;;; performancers, sound engeneers and other music artists.
;;;
;;; Copyright © 2020 Mikhail Kirillov <w96k@posteo.net>
;;;
;;; This file is part of Doujinhub
;;;
;;; Doujinhub is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Doujinhub is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Doujinhub.  If not, see <http://www.gnu.org/licenses/>.

;; Virtual environment for a project
;;
;; We use guix to create something similar to python virtual
;; environment, but its not limited only to python. We can use it
;; almost for everything.

(define-module (non-gnu packages doujinhub)
  #:use-module (non-gnu packages mini-css)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix build-system python)
  #:use-module (guix build-system trivial)
  #:use-module (guix build utils)
  #:use-module (guix gexp)
  #:use-module (gnu packages base)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-web)
  #:use-module ((guix licenses) #:prefix license:))

;; Return package for guix environment cli command
(define-public doujinhub
  (package
    (name "doujinhub")
    (version "0.0.1")
    (source (local-file "." "doujinhub" #:recursive? #t))
    (build-system trivial-build-system)
    ;;(native-inputs
    ;;())
    (propagated-inputs
     `(("python-flask" ,python-flask)
       ("python-flask-wtf" ,python-flask-wtf)
       ("python-flask-sqlalchemy" ,python-flask-sqlalchemy)
       ))
    (inputs
     `(("python" ,python)))
    (native-inputs
     `(("coreutils" ,coreutils) ;; For navigating in virtual environment
       ("mini-css" ,mini-css) ;; Stylesheets for a project
       )
     )
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
	 (use-modules (guix build utils))

	 (newline)
	 (display %build-inputs)
	 
	 (let ((out (assoc-ref %outputs "out"))
	       (coreutils (assoc-ref %build-inputs "coreutils"))
	       (mini-css (assoc-ref %build-inputs "mini-css"))
	       (source (assoc-ref %build-inputs "source")))
	   
	   (mkdir out)
	   (mkdir (string-append out "/bin"))

	   ;; Copy code of the project
	   (copy-recursively (string-append source "/app") out)

	   ;; Copy mini.css in /public folder
	   (copy-recursively (string-append mini-css "/lib/node_modules/mini.css/src/mini/")
			     (string-append out "/css/mini.css"))
	   ))))
    (synopsis "Web-service for a collaboration between performance,
composers and sound engeneers.")
    (description "Web-service for a collaboration between performance,
composers and sound engeneers.")
    (home-page "https://doujinhub.com")
    (license license:gpl3)))

A guix/non-gnu/packages/mini-css.scm => guix/non-gnu/packages/mini-css.scm +60 -0
@@ 0,0 1,60 @@
;;; Doujinhub --- Web-service for a collaboration between composers,
;;; performancers, sound engeneers and other music artists.
;;;
;;; Copyright © 2020 Mikhail Kirillov <w96k@posteo.net>
;;;
;;; This file is part of Doujinhub
;;;
;;; Doujinhub is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Doujinhub is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Doujinhub.  If not, see <http://www.gnu.org/licenses/>.

(define-module (non-gnu packages mini-css)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix build-system node)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages node))

(define-public mini-css
  (package
    (name "mini.css")
    (version "3.0.1")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
	     (url "https://github.com/Chalarangelo/mini.css")
	     (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
	(base32
	 "0fgp7hqfv5qvbgvkvf8k00ac5div0lmc3gm3rk6x7k5qsdhvcfhg"))))
    (build-system node-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
	 (add-after 'install 'bin-delete
	   (lambda* (#:key inputs outputs #:allow-other-keys)
	     (delete-file (string-append (assoc-ref %outputs "out") "/bin"))
	     #t))
	 )))
    (synopsis "A minimal, responsive, style-agnostic CSS framework.")
    (description "mini.css is a lightweight CSS framework (under 7KB
gzipped) designed with mobile devices and modern browsers in
mind. Responsiveness, ease of use and customization are some of the
main features of the framework, while accessibility and extensive
documentation are some of the secondary focuses of the project. The
framework is written using Sass, while most of its components are
based on Flexbox.")
    (home-page "https://minicss.org")
    (license license:expat)))

A install.sh => install.sh +3 -0
@@ 0,0 1,3 @@
cd app/
guix download https://github.com/Chalarangelo/mini.css \
     -o css/test.tar.gz