devenv
This commit is contained in:
parent
e1605aab29
commit
91f924a75a
|
@ -0,0 +1,2 @@
|
|||
# devenv needs to know the path to the current working directory to create and manage mutable state
|
||||
use flake . --no-pure-eval
|
|
@ -1,5 +1,6 @@
|
|||
result
|
||||
result-*
|
||||
.venv
|
||||
.direnv
|
||||
.devenv
|
||||
|
||||
|
|
18
README.md
18
README.md
|
@ -6,7 +6,23 @@ EDB-system for PVVVV
|
|||
|
||||
### Hvordan kjøre
|
||||
|
||||
nix run github:Prograrmvarverkstedet/dibbler
|
||||
nix run github:Programvareverkstedet/dibbler
|
||||
|
||||
### Hvordan utvikle?
|
||||
|
||||
python -m venv .venv
|
||||
source .venv/activate
|
||||
pip install -e .
|
||||
cp example-config.ini config.ini
|
||||
dibbler -c config.ini create-db
|
||||
dibbler -c config.ini loop
|
||||
|
||||
eller hvis du tolererer nix og postgres:
|
||||
|
||||
direnv allow # eller bare `nix develop`
|
||||
devenv up
|
||||
dibbler create-db
|
||||
dibbler loop
|
||||
|
||||
### Bygge image
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import os
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from dibbler.conf import config
|
||||
|
||||
engine = create_engine(config.get("database", "url"))
|
||||
engine = create_engine(
|
||||
os.environ.get("DIBBLER_DATABASE_URL")
|
||||
or config.get("database", "url")
|
||||
)
|
||||
Session = sessionmaker(bind=engine)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import argparse
|
||||
import sys
|
||||
import os
|
||||
|
||||
from dibbler.conf import config
|
||||
|
||||
|
@ -10,6 +12,7 @@ parser.add_argument(
|
|||
help="Path to the config file",
|
||||
type=str,
|
||||
required=False,
|
||||
default=os.environ.get("DIBBLER_CONFIG_FILE", None)
|
||||
)
|
||||
|
||||
subparsers = parser.add_subparsers(
|
||||
|
@ -24,6 +27,8 @@ subparsers.add_parser("slabbedasker", help="Find out who is slabbedasker")
|
|||
|
||||
def main():
|
||||
args = parser.parse_args()
|
||||
if args.config is None:
|
||||
print("ERROR: no config was provided", file=sys.stderr)
|
||||
config.read(args.config)
|
||||
|
||||
if args.subcommand == "loop":
|
||||
|
|
|
@ -7,8 +7,8 @@ show_tracebacks = true
|
|||
input_encoding = 'utf8'
|
||||
|
||||
[database]
|
||||
url = sqlite:///test.db
|
||||
; url = postgresql://dibbler:hunter2@localhost/dibbler
|
||||
; url = postgresql://dibbler:hunter2@127.0.0.1/pvvvv
|
||||
url = sqlite:///test.db ; devenv will override this to postgres using DIBBLER_DATABASE_URL
|
||||
|
||||
[limits]
|
||||
low_credit_warning_limit = -100
|
||||
|
|
250
flake.lock
250
flake.lock
|
@ -1,15 +1,103 @@
|
|||
{
|
||||
"nodes": {
|
||||
"cachix": {
|
||||
"inputs": {
|
||||
"devenv": [
|
||||
"devenv"
|
||||
],
|
||||
"flake-compat": [
|
||||
"devenv"
|
||||
],
|
||||
"git-hooks": [
|
||||
"devenv"
|
||||
],
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1728672398,
|
||||
"narHash": "sha256-KxuGSoVUFnQLB2ZcYODW7AVPAh9JqRlD5BrfsC/Q4qs=",
|
||||
"owner": "cachix",
|
||||
"repo": "cachix",
|
||||
"rev": "aac51f698309fd0f381149214b7eee213c66ef0a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"ref": "latest",
|
||||
"repo": "cachix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devenv": {
|
||||
"inputs": {
|
||||
"cachix": "cachix",
|
||||
"flake-compat": "flake-compat",
|
||||
"git-hooks": "git-hooks",
|
||||
"nix": "nix",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731619804,
|
||||
"narHash": "sha256-wyxFaVooL8SzvQNpolpx32X+GoBPnCAg9E0i/Ekn3FU=",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"rev": "87edaaf1dddf17fe16eabab3c8edaf7cca2c3bc2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"devenv",
|
||||
"nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1712014858,
|
||||
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1692799911,
|
||||
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -18,7 +106,154 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": [
|
||||
"devenv"
|
||||
],
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"devenv",
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": [
|
||||
"devenv"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730302582,
|
||||
"narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"devenv",
|
||||
"git-hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"libgit2": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1697646580,
|
||||
"narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=",
|
||||
"owner": "libgit2",
|
||||
"repo": "libgit2",
|
||||
"rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "libgit2",
|
||||
"repo": "libgit2",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix": {
|
||||
"inputs": {
|
||||
"flake-compat": [
|
||||
"devenv"
|
||||
],
|
||||
"flake-parts": "flake-parts",
|
||||
"libgit2": "libgit2",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixpkgs-23-11": [
|
||||
"devenv"
|
||||
],
|
||||
"nixpkgs-regression": [
|
||||
"devenv"
|
||||
],
|
||||
"pre-commit-hooks": [
|
||||
"devenv"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727438425,
|
||||
"narHash": "sha256-X8ES7I1cfNhR9oKp06F6ir4Np70WGZU5sfCOuNBEwMg=",
|
||||
"owner": "domenkozar",
|
||||
"repo": "nix",
|
||||
"rev": "f6c5ae4c1b2e411e6b1e6a8181cc84363d6a7546",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "domenkozar",
|
||||
"ref": "devenv-2.24",
|
||||
"repo": "nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1730531603,
|
||||
"narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1717432640,
|
||||
"narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "88269ab3044128b7c2f4c7d68448b2fb50456870",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "release-24.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1716977621,
|
||||
"narHash": "sha256-Q1UQzYcMJH4RscmpTkjlgqQDX5yi1tZL0O345Ri6vXQ=",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv-nixpkgs",
|
||||
"rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"ref": "rolling",
|
||||
"repo": "devenv-nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1731611831,
|
||||
"narHash": "sha256-R51rOqkWMfubBkZ9BY4Y1VaRoeqEBshlfQ8mMH5RjqI=",
|
||||
|
@ -28,14 +263,17 @@
|
|||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable-small",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devenv": "devenv",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs_4"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
|
87
flake.nix
87
flake.nix
|
@ -1,33 +1,85 @@
|
|||
{
|
||||
description = "Dibbler samspleisebod";
|
||||
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
devenv.url = "github:cachix/devenv";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
nixConfig = {
|
||||
extra-trusted-public-keys = [
|
||||
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
|
||||
];
|
||||
extra-substituters = [
|
||||
"https://devenv.cachix.org"
|
||||
];
|
||||
};
|
||||
|
||||
outputs = { self, ... } @ inputs:
|
||||
inputs.flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) lib;
|
||||
in {
|
||||
|
||||
packages = {
|
||||
default = self.packages.${system}.dibbler;
|
||||
dibbler = pkgs.python311Packages.callPackage ./nix/dibbler.nix { };
|
||||
};
|
||||
|
||||
apps = {
|
||||
default = self.apps.${system}.dibbler;
|
||||
dibbler = flake-utils.lib.mkApp {
|
||||
drv = self.packages.${system}.dibbler;
|
||||
};
|
||||
dibbler = pkgs.python311Packages.callPackage ./nix/dibbler.nix { };
|
||||
skrot-vm = self.nixosConfigurations.skrot.config.system.build.vm;
|
||||
|
||||
# devenv cruft
|
||||
devenv-up = self.devShells.${system}.default.config.procfileScript;
|
||||
devenv-test = self.devShells.${system}.default.config.test;
|
||||
};
|
||||
|
||||
devShells = {
|
||||
default = self.devShells.${system}.dibbler;
|
||||
dibbler = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
python311Packages.black
|
||||
ruff
|
||||
dibbler = inputs.devenv.lib.mkShell {
|
||||
inherit inputs pkgs;
|
||||
modules = [({ config, ... }: {
|
||||
# https://devenv.sh/reference/options/
|
||||
|
||||
enterShell = ''
|
||||
if [[ ! -f config.ini ]]; then
|
||||
cp -v example-config.ini config.ini
|
||||
fi
|
||||
|
||||
export REPO_ROOT=$(realpath .) # used by mkPythonEditablePackage
|
||||
export DIBBLER_CONFIG_FILE=$(realpath config.ini)
|
||||
export DIBBLER_DATABASE_URL=postgresql://dibbler:hunter2@/dibbler?host=${config.env.PGHOST}
|
||||
'';
|
||||
|
||||
packages = [
|
||||
|
||||
/* self.packages.${system}.dibbler */
|
||||
(pkgs.python311Packages.mkPythonEditablePackage {
|
||||
inherit (self.packages.${system}.dibbler)
|
||||
pname version
|
||||
build-system dependencies;
|
||||
scripts = (lib.importTOML ./pyproject.toml).project.scripts;
|
||||
root = "$REPO_ROOT";
|
||||
})
|
||||
|
||||
pkgs.python311Packages.black
|
||||
pkgs.ruff
|
||||
];
|
||||
|
||||
services.postgres = {
|
||||
enable = true;
|
||||
initialDatabases = [
|
||||
{
|
||||
name = "dibbler";
|
||||
user = "dibbler";
|
||||
pass = "hunter2";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
})];
|
||||
};
|
||||
};
|
||||
|
||||
})
|
||||
|
||||
//
|
||||
|
@ -39,10 +91,10 @@
|
|||
|
||||
images.skrot = self.nixosConfigurations.skrot.config.system.build.sdImage;
|
||||
|
||||
nixosConfigurations.skrot = nixpkgs.lib.nixosSystem {
|
||||
nixosConfigurations.skrot = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "aarch64-linux";
|
||||
modules = [
|
||||
(nixpkgs + "/nixos/modules/installer/sd-card/sd-image-aarch64.nix")
|
||||
(inputs.nixpkgs + "/nixos/modules/installer/sd-card/sd-image-aarch64.nix")
|
||||
self.nixosModules.default
|
||||
({...}: {
|
||||
system.stateVersion = "22.05";
|
||||
|
@ -71,5 +123,6 @@
|
|||
})
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,14 +11,15 @@
|
|||
|
||||
buildPythonApplication {
|
||||
pname = "dibbler";
|
||||
version = "0-unstable-2021-09-07";
|
||||
version = "0.0.0";
|
||||
pyproject = true;
|
||||
|
||||
src = lib.cleanSource ../.;
|
||||
|
||||
built-system = [ setuptools ];
|
||||
build-system = [ setuptools ];
|
||||
dependencies = [
|
||||
brother-ql#-next
|
||||
# we override pname to satisfy mkPythonEditablePackage
|
||||
(brother-ql.overridePythonAttrs { pname = "brother-ql-next"; })
|
||||
matplotlib
|
||||
psycopg2
|
||||
python-barcode
|
||||
|
|
Loading…
Reference in New Issue