Add paperless, up guest VM RAM to 48GB

This commit is contained in:
Benjamin Bädorf 2022-03-10 21:32:21 +01:00
parent d047a4aac0
commit 33f03b3f0d
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
8 changed files with 621 additions and 184 deletions

611
flake.lock Normal file
View file

@ -0,0 +1,611 @@
{
"nodes": {
"agenix": {
"inputs": {
"nixpkgs": [
"nixos"
]
},
"locked": {
"lastModified": 1646105662,
"narHash": "sha256-jdXCZbGZL0SWWi29GnAOFHUh/QvvP0IyaVLv1ZTDkBI=",
"owner": "ryantm",
"repo": "agenix",
"rev": "297cd58b418249240b9f1f155d52b1b17f292884",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"beautysh": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"poetry2nix": "poetry2nix"
},
"locked": {
"lastModified": 1641830469,
"narHash": "sha256-uhDmgNP/biOWe4FtOa6c2xZnREH+NP9rdrMm0LccRUk=",
"owner": "lovesegfault",
"repo": "beautysh",
"rev": "e85d9736927c0fcf2abb05cb3a2d8d9b4502a2eb",
"type": "github"
},
"original": {
"owner": "lovesegfault",
"repo": "beautysh",
"type": "github"
}
},
"blank": {
"locked": {
"lastModified": 1625557891,
"narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=",
"owner": "divnix",
"repo": "blank",
"rev": "5a5d2684073d9f563072ed07c871d577a6c614a8",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "blank",
"type": "github"
}
},
"bud": {
"inputs": {
"beautysh": "beautysh",
"devshell": [
"digga",
"devshell"
],
"nixpkgs": [
"nixos"
]
},
"locked": {
"lastModified": 1642035816,
"narHash": "sha256-1Lq5c1AeUv/1SK08+O704JVfDdD/zodHzA0cv0TIga8=",
"owner": "divnix",
"repo": "bud",
"rev": "a789d710851441ba7e7cd59be378623b1fe05688",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "bud",
"type": "github"
}
},
"darwin": {
"inputs": {
"nixpkgs": [
"nixos"
]
},
"locked": {
"lastModified": 1645293039,
"narHash": "sha256-PwdDu+SkX8dreeuJ/4av1sEluNZdrpdXv8JsRKKg1Yc=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "1df878b6f8351795a3bebfbe4fd2d02e1e8b29d6",
"type": "github"
},
"original": {
"owner": "LnL7",
"repo": "nix-darwin",
"type": "github"
}
},
"deploy": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixos"
],
"utils": "utils"
},
"locked": {
"lastModified": 1643787431,
"narHash": "sha256-8IwuVgXulRE3ZWq6z8mytarawC32pKPKR20EyDtSH+w=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "4154ba1aaaf7333a916384c348d867d03b6f1409",
"type": "github"
},
"original": {
"owner": "serokell",
"repo": "deploy-rs",
"type": "github"
}
},
"devshell": {
"locked": {
"lastModified": 1637575296,
"narHash": "sha256-ZY8YR5u8aglZPe27+AJMnPTG6645WuavB+w0xmhTarw=",
"owner": "numtide",
"repo": "devshell",
"rev": "0e56ef21ba1a717169953122c7415fa6a8cd2618",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"digga": {
"inputs": {
"blank": "blank",
"deploy": [
"deploy"
],
"devshell": "devshell",
"flake-compat": "flake-compat_2",
"flake-utils-plus": "flake-utils-plus",
"home-manager": [
"home"
],
"latest": "latest",
"nixlib": [
"nixos"
],
"nixos-generators": "nixos-generators",
"nixpkgs": [
"nixos"
]
},
"locked": {
"lastModified": 1646340536,
"narHash": "sha256-mXNWDqHDGqGRIE7RxN6nkhQyZcikJL2HAvu55ITuC98=",
"owner": "divnix",
"repo": "digga",
"rev": "bfecf143c098581e0aafe1b8f9e3f2f7a402fb17",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "digga",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1627913399,
"narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1631561581,
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils-plus": {
"inputs": {
"flake-utils": "flake-utils_3"
},
"locked": {
"lastModified": 1639385028,
"narHash": "sha256-oqorKz3mwf7UuDJwlbCEYCB2LfcWLL0DkeCWhRIL820=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "be1be083af014720c14f3b574f57b6173b4915d0",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_5": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home": {
"inputs": {
"nixpkgs": [
"nixos"
]
},
"locked": {
"lastModified": 1643933536,
"narHash": "sha256-yRmsWAG4DnLxLIUtlaZsl0kH7rN5xSoyNRlf0YZrcH4=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2860d7e3bb350f18f7477858f3513f9798896831",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-21.11",
"repo": "home-manager",
"type": "github"
}
},
"latest": {
"locked": {
"lastModified": 1638198142,
"narHash": "sha256-plU9b8r4St6q4U7VHtG9V7oF8k9fIpfXl/KDaZLuY9k=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8a308775674e178495767df90c419425474582a1",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"latest_2": {
"locked": {
"lastModified": 1646254136,
"narHash": "sha256-8nQx02tTzgYO21BP/dy5BCRopE8OwE8Drsw98j+Qoaw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3e072546ea98db00c2364b81491b893673267827",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"nixos"
]
},
"locked": {
"lastModified": 1639947939,
"narHash": "sha256-pGsM8haJadVP80GFq4xhnSpNitYNQpaXk4cnA796Cso=",
"owner": "nmattia",
"repo": "naersk",
"rev": "2fc8ce9d3c025d59fee349c1f80be9785049d653",
"type": "github"
},
"original": {
"owner": "nmattia",
"repo": "naersk",
"type": "github"
}
},
"nix-dram": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": [
"latest"
]
},
"locked": {
"lastModified": 1644066500,
"narHash": "sha256-15PCSlsvYQOwJ+Jvp9evrBiun4pquPAh5VZAUO5whcw=",
"owner": "dramforever",
"repo": "nix-dram",
"rev": "579d5a3db2cb4726653a0916e0f210dbb84cb0a5",
"type": "github"
},
"original": {
"owner": "dramforever",
"repo": "nix-dram",
"type": "github"
}
},
"nixlib": {
"locked": {
"lastModified": 1641688481,
"narHash": "sha256-6L+EU12xLDHby7y8elgFtRKVBxix+7qV8DhVgXqrKZo=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f697717b3d3a074ffc16c8c8227504f0db292886",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos": {
"locked": {
"lastModified": 1646358457,
"narHash": "sha256-rzvpqPRX5q5sOUbu7lhZkk9vhnIVWSARnu+R9mSE3Vc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0fc9d50c3104c8ddb11cf0c83a045eb78ad17058",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixlib": "nixlib",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1637655461,
"narHash": "sha256-kXZPbclN3gKwjhp2/RYFDFpAsSBwzX1iLF4EcnHZsPQ=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "05a3eb158a9c7746a5d463726d7f7cccf07500e4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1646398322,
"narHash": "sha256-p+WCAOoJLc4R6x60pLYYqAiq30PlDUYJMrXqQ3rkBCg=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "a7bca8d0d8188ae9802ecc467150cf018e19b958",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1633971123,
"narHash": "sha256-WmI4NbH1IPGFWVkuBkKoYgOnxgwSfWDgdZplJlQ93vA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e4ef597edfd8a0ba5f12362932fc9b1dd01a0aef",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable-small",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1646943458,
"narHash": "sha256-qgGBWULyReIEdRg/k52Tv4Eognyk8S9360oxem+1qFY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b3b026509758cebbaa4e3173c1f1531102b28b64",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1646506091,
"narHash": "sha256-sWNAJE2m+HOh1jtXlHcnhxsj6/sXrHgbqVNcVRlveK4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3e644bd62489b516292c816f70bf0052c693b3c7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1626378135,
"narHash": "sha256-koC6DBYmLCrgXA+AMHVaODf1uHYPmvcFygHfy3eg6vI=",
"path": "/nix/store/6mfkswqi67m35qwv0vh7kpk8rypbl2rq-source",
"rev": "00c2ec8f0bbdf0cfb2135bde55fbae5d6b64aa6d",
"type": "path"
},
"original": {
"id": "nur",
"type": "indirect"
}
},
"nvfetcher": {
"inputs": {
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_5",
"nixpkgs": [
"nixos"
]
},
"locked": {
"lastModified": 1644123018,
"narHash": "sha256-xEhhLmuy4FnT4Zdkf3epPX9T3xqn59yERCsicG4IEyM=",
"owner": "berberman",
"repo": "nvfetcher",
"rev": "9f2cb15c4668859312b6a854d79ad753d5b98b03",
"type": "github"
},
"original": {
"owner": "berberman",
"repo": "nvfetcher",
"type": "github"
}
},
"poetry2nix": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1633382856,
"narHash": "sha256-hYlet806M9xJj4yxf0g5fhDT2IEUVIMAl7sqIeZ8DUM=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "705cbfa10e3d9bfed2e59e0256844ae3704dbd7e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"bud": "bud",
"darwin": "darwin",
"deploy": "deploy",
"digga": "digga",
"home": "home",
"latest": "latest_2",
"naersk": "naersk",
"nix-dram": "nix-dram",
"nixos": "nixos",
"nixos-hardware": "nixos-hardware",
"nur": "nur",
"nvfetcher": "nvfetcher"
}
},
"utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -13,8 +13,8 @@ in
<libosinfo:os id="${vm.id}"/>
</libosinfo:libosinfo>
</metadata>
<memory unit='KiB'>33554432</memory>
<currentMemory unit='KiB'>33554432</currentMemory>
<memory unit='KiB'>50331648</memory>
<currentMemory unit='KiB'>50331648</currentMemory>
<vcpu placement='static'>12</vcpu>
<cputune>
<vcpupin vcpu='0' cpuset='6'/>
@ -96,7 +96,7 @@ in
<devices>
<emulator>${pkgs.qemu}/bin/qemu-system-x86_64</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<driver name='qemu' type='raw' cache='none' discard='unmap' />
<source dev='${vm.disk}'/>
<backingStore/>
<target dev='vdb' bus='virtio'/>

View file

@ -6,10 +6,6 @@ let
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
in
{
imports = [
./scanbd.nix
];
options.pub-solar.paperless = {
enable = mkEnableOption "All you need to go paperless";
ocrLanguage = mkOption {
@ -27,7 +23,6 @@ in
};
config = mkIf cfg.enable {
services.scanbd.enable = true;
services.paperless-ng = {
enable = true;
consumptionDir = cfg.consumptionDir;

View file

@ -1,176 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
configDir = "/etc/scanbd";
saneConfigDir = "${configDir}/sane.d";
cfg = config.pub-solar.paperless;
scanbdConf = pkgs.writeText "scanbd.conf"
''
global {
debug = true
debug-level = ${toString config.services.scanbd.debugLevel}
user = ${config.services.scanbd.user}
group = ${config.services.scanbd.group}
scriptdir = ${configDir}/scripts
pidfile = ${config.services.scanbd.pidFile}
timeout = ${toString config.services.scanbd.timeOut}
environment {
device = "SCANBD_DEVICE"
action = "SCANBD_ACTION"
}
multiple_actions = true
action scan {
numerical-trigger {
from-value = 1
to-value = 0
}
desc = "Scan to file"
script = "scan.script"
}
${config.services.scanbd.extraConfig}
}
'';
scanScript = pkgs.writeScript "scanbd_scan.script"
''
#! ${pkgs.bash}/bin/bash
export PATH=${lib.makeBinPath [ pkgs.coreutils pkgs.sane-frontends pkgs.sane-backends pkgs.ghostscript pkgs.imagemagick ]}
set -x
date="$(date --iso-8601=seconds)"
filename="Scan $date.pdf"
tmpdir="$(mktemp -d)"
exec 3>&1 1>>"/tmp/$filename.log" 2>&1
pushd "$tmpdir"
scanadf -d "$SCANBD_DEVICE" --resolution 300dpi
# Convert any PNM images produced by the scan into a PDF with the date as a name
convert image* -density 200 "$filename"
chmod 0666 "$filename"
# Remove temporary PNM images
rm --verbose image*
# Atomic move converted PDF to destination directory
paperlessdir="${cfg.consumptionDir}"
cp -pv "$filename" $paperlessdir/"$filename".tmp &&
mv $paperlessdir/"$filename".tmp $paperlessdir/"$filename" &&
rm "$filename"
popd
rm -r "$tmpdir"
'';
in
{
###### interface
options = {
services.scanbd.enable = mkOption {
type = types.bool;
default = false;
description = ''
Enable support for scanbd (scanner button daemon).
<note><para>
If scanbd is enabled, then saned must be disabled.
</para></note>
'';
};
services.scanbd.user = mkOption {
type = types.str;
default = "scanner";
example = "";
description = ''
scanbd daemon user name.
'';
};
services.scanbd.group = mkOption {
type = types.str;
default = "scanner";
example = "";
description = ''
scanbd daemon group name.
'';
};
services.scanbd.extraConfig = mkOption {
type = types.lines;
default = "";
example = ''
device canon {
filter = "^genesys.*"
desc = "Canon LIDE"
action file {
filter = "^file.*"
desc = "File"
script = "copy.script"
}
}
'';
description = ''
Extra configuration lines included verbatim in scanbd.conf.
Use e.g. in lieu of including device-specific config templates
under scanner.d/
'';
};
services.scanbd.pidFile = mkOption {
type = types.str;
default = "/var/run/scanbd.pid";
example = "";
description = ''
PID file path.
'';
};
services.scanbd.timeOut = mkOption {
type = types.int;
default = 500;
example = "";
description = ''
Device polling timeout (in ms).
'';
};
services.scanbd.debugLevel = mkOption {
type = types.int;
default = 3;
example = "";
description = ''
Debug logging (1=error, 2=warn, 3=info, 4-7=debug)
'';
};
};
###### implementation
config = mkIf config.services.scanbd.enable {
users.groups.scanner.gid = config.ids.gids.scanner;
users.users.scanner = {
uid = config.ids.uids.scanner;
group = "scanner";
};
environment.etc."scanbd/scanbd.conf".source = scanbdConf;
environment.etc."scanbd/scripts/scan.script".source = scanScript;
environment.etc."scanbd/scripts/test.script".source = "${pkgs.scanbd}/etc/scanbd/test.script";
systemd.services.scanbd = {
enable = true;
description = "Scanner button polling service";
documentation = [ "https://sourceforge.net/p/scanbd/code/HEAD/tree/releases/1.5.1/integration/systemd/README.systemd" ];
script = "${pkgs.scanbd}/bin/scanbd -c ${configDir}/scanbd.conf -f";
wantedBy = [ "multi-user.target" ];
aliases = [ "dbus-de.kmux.scanbd.server.service" ];
};
};
}

View file

@ -24,6 +24,7 @@ channels: final: prev: {
obs-studio
obs-studio-plugins
looking-glass-client
itch
;

View file

@ -16,4 +16,6 @@ with final; {
toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final);
uhk-agent = import ./uhk-agent.nix final;
wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final);
scan2paperless = writeShellScriptBin "scan2paperless" (import ./scan2paperless.nix final);
}

3
pkgs/scan2paperless.nix Normal file
View file

@ -0,0 +1,3 @@
self: with self; ''
export PATH=${lib.makeBinPath [ pkgs.coreutils pkgs.sane-frontends pkgs.sane-backends pkgs.ghostscript pkgs.imagemagick ]}
''

View file

@ -13,6 +13,7 @@ in
home.packages = with pkgs; [
dogecoin
nodejs
itch
];
programs.ssh = {