split up the flake better
This commit is contained in:
parent
d6e6bd7768
commit
c8ce4db2a2
2 changed files with 47 additions and 21 deletions
67
flake.nix
67
flake.nix
|
|
@ -20,6 +20,27 @@
|
||||||
serverProject = inputs.pyproject-nix.lib.project.loadPyproject {
|
serverProject = inputs.pyproject-nix.lib.project.loadPyproject {
|
||||||
projectRoot = ./.;
|
projectRoot = ./.;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Packages
|
||||||
|
script = pkgs.writeShellApplication {
|
||||||
|
name = "scanbuddy";
|
||||||
|
|
||||||
|
runtimeInputs = with pkgs; [sane-backends brscan5 ghostscript];
|
||||||
|
|
||||||
|
text = builtins.readFile ./scanbuddy.bash;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Returns an attribute set that can be passed to `buildPythonPackage`.
|
||||||
|
attrs = serverProject.renderers.buildPythonPackage {inherit python;};
|
||||||
|
server = python.pkgs.buildPythonPackage (attrs
|
||||||
|
// {
|
||||||
|
env.CUSTOM_ENVVAR = "foobar";
|
||||||
|
});
|
||||||
|
|
||||||
|
scanbuddy-pkg = pkgs.symlinkJoin {
|
||||||
|
name = "scanbuddy";
|
||||||
|
paths = [script server];
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
# devShells.${system}.default = pkgs.mkShell {
|
# devShells.${system}.default = pkgs.mkShell {
|
||||||
# packages = with pkgs; [
|
# packages = with pkgs; [
|
||||||
|
|
@ -33,28 +54,32 @@
|
||||||
# exec zsh
|
# exec zsh
|
||||||
# '';
|
# '';
|
||||||
# };
|
# };
|
||||||
packages.${system} = let
|
packages.${system} = {
|
||||||
scanbuddy = pkgs.writeShellApplication {
|
default = scanbuddy-pkg;
|
||||||
name = "scanbuddy";
|
inherit script;
|
||||||
|
|
||||||
runtimeInputs = with pkgs; [sane-backends brscan5 ghostscript];
|
|
||||||
|
|
||||||
text = builtins.readFile ./scanbuddy.bash;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Returns an attribute set that can be passed to `buildPythonPackage`.
|
|
||||||
attrs = serverProject.renderers.buildPythonPackage {inherit python;};
|
|
||||||
server = python.pkgs.buildPythonPackage (attrs
|
|
||||||
// {
|
|
||||||
env.CUSTOM_ENVVAR = "foobar";
|
|
||||||
});
|
|
||||||
in {
|
|
||||||
default = pkgs.symlinkJoin {
|
|
||||||
name = "scanbuddy";
|
|
||||||
paths = [scanbuddy server];
|
|
||||||
};
|
|
||||||
inherit scanbuddy;
|
|
||||||
inherit server;
|
inherit server;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixosModules.default = {
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
options = {
|
||||||
|
service.scanbuddy = lib.mkEnableOption "Enable the scanbuddy server";
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
systemd.services.scanbuddy = lib.mkIf config.service.scanbuddy {
|
||||||
|
description = "The scanbuddy webservice";
|
||||||
|
wantedBy = ["multi-user.target"];
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${scanbuddy-pkg}/bin/scanbuddy-server";
|
||||||
|
Path = ["${scanbuddy-pkg}/bin"];
|
||||||
|
WorkingDirectory = "/var/lib/scanbuddy";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ description = "A REST server for the scanbuddy shell-script"
|
||||||
# define any Python dependencies
|
# define any Python dependencies
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flask>3",
|
"flask>3",
|
||||||
|
"waitress"
|
||||||
]
|
]
|
||||||
|
|
||||||
# define the CLI executable
|
# define the CLI executable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue