Merge branch 'master' of git.uninsane.org:shelvacu/nix-stuff
This commit is contained in:
@@ -185,6 +185,7 @@ in
|
||||
jq
|
||||
killall
|
||||
libossp_uuid # provides `uuid` binary
|
||||
linuxquota
|
||||
lsof
|
||||
mosh
|
||||
nano
|
||||
|
32
flake.nix
32
flake.nix
@@ -254,22 +254,24 @@
|
||||
};
|
||||
};
|
||||
|
||||
nixOnDroidConfigurations.default = let
|
||||
pkgs = mkPkgs { system = arm; };
|
||||
in nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
modules = [
|
||||
./common
|
||||
./nix-on-droid
|
||||
];
|
||||
extraSpecialArgs = {
|
||||
inputs = mkInputs { };
|
||||
inherit (inputs) dns;
|
||||
inherit vacuModules;
|
||||
vaculib = import ./vaculib { inherit pkgs; };
|
||||
vacuModuleType = "nix-on-droid";
|
||||
nixOnDroidConfigurations.default =
|
||||
let
|
||||
pkgs = mkPkgs { system = arm; };
|
||||
in
|
||||
nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
modules = [
|
||||
./common
|
||||
./nix-on-droid
|
||||
];
|
||||
extraSpecialArgs = {
|
||||
inputs = mkInputs { };
|
||||
inherit (inputs) dns;
|
||||
inherit vacuModules;
|
||||
vaculib = import ./vaculib { inherit pkgs; };
|
||||
vacuModuleType = "nix-on-droid";
|
||||
};
|
||||
inherit pkgs;
|
||||
};
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
checks = nixpkgs.lib.genAttrs [ x86 ] (
|
||||
system:
|
||||
|
@@ -797,19 +797,28 @@ let
|
||||
${pure_flags [ "genshin" "D" ] (envelope_is "genshin@shelvacu.com")}
|
||||
${pure_flags [ "jork" "B" ] (envelope_is "jork@shelvacu.com")}
|
||||
${pure_flags [ "patreon" "not-spamish" ] (envelope_is "patreon@shelvacu.com")}
|
||||
${pure_flags [ "patreon-post" "B.subscriptions" ] [
|
||||
(has_flag "patreon")
|
||||
(header_is "X-Mailgun-Tag" "template_newsletterpostcontrol")
|
||||
]}
|
||||
${pure_flags [ "patreon-free-member-digest" "D" ] [
|
||||
(has_flag "patreon")
|
||||
(header_is "X-Mailgun-Tag" "template_freememberdigest")
|
||||
]}
|
||||
${pure_flags [ "patreon-other" "B" ] [
|
||||
(has_flag "patreon")
|
||||
(not (has_flag "patreon-post"))
|
||||
(not (has_flag "patreon-free-member-digest"))
|
||||
]}
|
||||
${pure_flags
|
||||
[ "patreon-post" "B.subscriptions" ]
|
||||
[
|
||||
(has_flag "patreon")
|
||||
(header_is "X-Mailgun-Tag" "template_newsletterpostcontrol")
|
||||
]
|
||||
}
|
||||
${pure_flags
|
||||
[ "patreon-free-member-digest" "D" ]
|
||||
[
|
||||
(has_flag "patreon")
|
||||
(header_is "X-Mailgun-Tag" "template_freememberdigest")
|
||||
]
|
||||
}
|
||||
${pure_flags
|
||||
[ "patreon-other" "B" ]
|
||||
[
|
||||
(has_flag "patreon")
|
||||
(not (has_flag "patreon-post"))
|
||||
(not (has_flag "patreon-free-member-digest"))
|
||||
]
|
||||
}
|
||||
${pure_flags [ "rsb" "B" ] (from_is "support@rapidseedbox.com")}
|
||||
${pure_flags [ "fresh-avocado-dis8" "D" ] (envelope_is "fresh.avocado@dis8.net")}
|
||||
${pure_flags [ "discord" "A" ] (envelope_matches "discord@*")}
|
||||
|
@@ -81,13 +81,19 @@ in
|
||||
enable = true;
|
||||
package = cfg.lfs.package;
|
||||
};
|
||||
vacu.git.config = lib.mkIf cfg.lfs.enable (let bin = lib.getExe cfg.lfs.package; in {
|
||||
filter.lfs = {
|
||||
clean = "${bin} clean -- %f";
|
||||
smudge = "${bin} smudge -- %f";
|
||||
process = "${bin} filter-process";
|
||||
required = true;
|
||||
};
|
||||
});
|
||||
vacu.git.config = lib.mkIf cfg.lfs.enable (
|
||||
let
|
||||
bin = lib.getExe cfg.lfs.package;
|
||||
in
|
||||
{
|
||||
filter.lfs = {
|
||||
clean = "${bin} clean -- %f";
|
||||
smudge = "${bin} smudge -- %f";
|
||||
process = "${bin} filter-process";
|
||||
required = true;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
} // lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
}
|
||||
// lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
|
@@ -74,7 +74,7 @@ in
|
||||
};
|
||||
extraArgs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
bandwidthMonitor = mkOption {
|
||||
|
@@ -80,4 +80,5 @@ in
|
||||
// lib.optionalAttrs (vacuModuleType == "nix-on-droid") {
|
||||
environment.etc.hosts.text = config.vacu.etcHostsText;
|
||||
};
|
||||
} // lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
}
|
||||
// lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
|
@@ -111,4 +111,5 @@ in
|
||||
// lib.optionalAttrs (vacuModuleType == "nix-on-droid") {
|
||||
environment.packages = config.vacu.finalPackageList;
|
||||
};
|
||||
} // lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
}
|
||||
// lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
|
@@ -91,4 +91,5 @@ in
|
||||
// lib.optionalAttrs (vacuModuleType == "nix-on-droid") {
|
||||
environment.etc."ssh/ssh_config".text = config.vacu.ssh.config;
|
||||
};
|
||||
} // lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
}
|
||||
// lib.optionalAttrs (vacuModuleType == "nixos") { _class = "nixos"; }
|
||||
|
@@ -464,7 +464,8 @@ in
|
||||
default = pkgs.writeFile "autoexec.cfg" cfg.autoexecLines;
|
||||
readOnly = true;
|
||||
};
|
||||
build.classes = mkAttrsOfClasses (classname:
|
||||
build.classes = mkAttrsOfClasses (
|
||||
classname:
|
||||
mkOption {
|
||||
type = types.pkg;
|
||||
default = pkgs.writeText "${classname}.cfg" cfg.classLines.${classname};
|
||||
|
4
nur.nix
4
nur.nix
@@ -3,6 +3,8 @@
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
packagePaths = import ./packages;
|
||||
shelPackages = builtins.mapAttrs (_: path: lib.callPackageWith (pkgs // shelPackages) path { }) packagePaths;
|
||||
shelPackages = builtins.mapAttrs (
|
||||
_: path: lib.callPackageWith (pkgs // shelPackages) path { }
|
||||
) packagePaths;
|
||||
in
|
||||
shelPackages
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
stdenv,
|
||||
@@ -31,7 +31,7 @@ let
|
||||
license = [ lib.licenses.asl20 ];
|
||||
sourceProvenance = [ lib.sourceTypes.fromSource ];
|
||||
# no mainProgram
|
||||
platforms = lib.platforms.all;
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
})
|
||||
// {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
lib,
|
||||
runCommandLocal,
|
||||
writeText,
|
||||
@@ -6,19 +6,21 @@
|
||||
let
|
||||
filePkg = writeText "shellvaculib.bash" (builtins.readFile ./shellvaculib.bash);
|
||||
in
|
||||
runCommandLocal "shellvaculib" {
|
||||
passthru.file = filePkg;
|
||||
runCommandLocal "shellvaculib"
|
||||
{
|
||||
passthru.file = filePkg;
|
||||
|
||||
meta = {
|
||||
description = "Bunch of misc shell functions I find useful";
|
||||
license = [ lib.licenses.mit ];
|
||||
sourceProvenance = [ lib.sourceTypes.fromSource ];
|
||||
# no mainProgram
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
} ''
|
||||
mkdir -p "$out"/share
|
||||
mkdir -p "$out"/bin
|
||||
ln -s ${filePkg} "$out"/share/shellvaculib.bash
|
||||
ln -s ${filePkg} "$out"/bin/shellvaculib.bash
|
||||
''
|
||||
meta = {
|
||||
description = "Bunch of misc shell functions I find useful";
|
||||
license = [ lib.licenses.mit ];
|
||||
sourceProvenance = [ lib.sourceTypes.fromSource ];
|
||||
# no mainProgram
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
||||
''
|
||||
mkdir -p "$out"/share
|
||||
mkdir -p "$out"/bin
|
||||
ln -s ${filePkg} "$out"/share/shellvaculib.bash
|
||||
ln -s ${filePkg} "$out"/bin/shellvaculib.bash
|
||||
''
|
||||
|
@@ -3,7 +3,15 @@ let
|
||||
btrfs-progs = pkgs.btrfs-progs;
|
||||
btrfs = "${btrfs-progs}/bin/btrfs";
|
||||
btrfsDevice = "/dev/mapper/prophecy-root-decrypted";
|
||||
btrfsOpts = [ "compress=zstd:2" "datacow" "datasum" "discard=async" "ssd_spread" "noatime" "fatal_errors=panic" ];
|
||||
btrfsOpts = [
|
||||
"compress=zstd:2"
|
||||
"datacow"
|
||||
"datasum"
|
||||
"discard=async"
|
||||
"ssd_spread"
|
||||
"noatime"
|
||||
"fatal_errors=panic"
|
||||
];
|
||||
in
|
||||
{
|
||||
fileSystems."/" = {
|
||||
|
@@ -19,11 +19,13 @@ in
|
||||
clientKeyPath = config.sops.secrets.hathClientKey.path;
|
||||
};
|
||||
};
|
||||
environment.persistence."/persistent".directories = [ {
|
||||
directory = "/var/lib/hath";
|
||||
user = config.vacu.hath.user;
|
||||
group = config.vacu.hath.group;
|
||||
mode = "u=rwx,g=,o=";
|
||||
} ];
|
||||
environment.persistence."/persistent".directories = [
|
||||
{
|
||||
directory = "/var/lib/hath";
|
||||
user = config.vacu.hath.user;
|
||||
group = config.vacu.hath.group;
|
||||
mode = "u=rwx,g=,o=";
|
||||
}
|
||||
];
|
||||
networking.firewall.allowedTCPPorts = [ port ];
|
||||
}
|
||||
|
@@ -1,10 +1,14 @@
|
||||
# flake8: noqa
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Any
|
||||
from dataclasses import dataclass
|
||||
from collections.abc import Callable
|
||||
|
||||
import humanfriendly
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -20,18 +24,20 @@ class ProcessResult[T]:
|
||||
return ProcessResult(stdout=new_stdout, returncode=self.returncode)
|
||||
|
||||
|
||||
def run(*cmd: str) -> ProcessResult[str]:
|
||||
print(f"running {cmd!r}")
|
||||
def run(*cmd: str, verbose=True) -> ProcessResult[str]:
|
||||
if verbose:
|
||||
print(f"running {cmd!r}")
|
||||
proc = subprocess.Popen(
|
||||
cmd, stdout=subprocess.PIPE, stderr=None, stdin=subprocess.DEVNULL, text=True
|
||||
)
|
||||
(stdout_data, _) = proc.communicate()
|
||||
print(f"finished, exit code {proc.returncode}")
|
||||
if verbose:
|
||||
print(f"finished, exit code {proc.returncode}")
|
||||
return ProcessResult(stdout=stdout_data, returncode=proc.returncode)
|
||||
|
||||
|
||||
def must_succeed(*cmd: str) -> str:
|
||||
res = run(*cmd)
|
||||
def must_succeed(*cmd: str, verbose=True) -> str:
|
||||
res = run(*cmd, verbose=verbose)
|
||||
assert res.success()
|
||||
return res.stdout
|
||||
|
||||
@@ -43,8 +49,8 @@ def parse_maybe_json(maybe_json: str) -> Any:
|
||||
return json.loads(maybe_json)
|
||||
|
||||
|
||||
def run_json(*cmd: str) -> ProcessResult[Any]:
|
||||
res = run(*cmd)
|
||||
def run_json(*cmd: str, verbose=True) -> ProcessResult[Any]:
|
||||
res = run(*cmd, verbose=verbose)
|
||||
return res.map(parse_maybe_json)
|
||||
|
||||
|
||||
@@ -79,6 +85,23 @@ def do_build(installable: str, impure: bool) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--min-space", default="50G")
|
||||
args = parser.parse_args()
|
||||
min_space_bytes = human_friendly.parse_size(args.min_space)
|
||||
min_space_text = human_friendly.format_size(min_space_bytes)
|
||||
|
||||
|
||||
def clean_if_space_needed():
|
||||
usage = shutil.disk_usage("/nix/store")
|
||||
if usage.free < min_space_bytes:
|
||||
free_space_text = human_friendly.format_size(usage.free)
|
||||
print(
|
||||
f"free space ({free_space_text}) is less than min ({min_space_text}), running a gc"
|
||||
)
|
||||
must_succeed("nix", "store", "gc")
|
||||
|
||||
|
||||
res = run_json("nix", "eval", ".#.", "--json", "--apply", "f: f.archival.archiveList")
|
||||
assert res.success()
|
||||
build_list = res.stdout
|
||||
@@ -88,6 +111,7 @@ for info in build_list:
|
||||
if info["broken"]:
|
||||
print(f"Skipping {name}, marked broken")
|
||||
continue
|
||||
clean_if_space_needed()
|
||||
res = do_build(f".#archival.drvs.{name}", impure=info["impure"])
|
||||
if not res:
|
||||
continue
|
||||
|
@@ -1 +1,4 @@
|
||||
{ writers }: writers.writePython3Bin "vacu-flake-archive" { } (builtins.readFile ./archive.py)
|
||||
{ python3Packages, writers }:
|
||||
writers.writePython3Bin "vacu-flake-archive" { libraries = [ python3Packages.humanfriendly ]; } (
|
||||
builtins.readFile ./archive.py
|
||||
)
|
||||
|
@@ -24,6 +24,7 @@
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-uuid/a4d6a30b-a8b1-460c-9f90-554e61b112fe";
|
||||
fsType = "f2fs";
|
||||
options = [ "usrquota" "grpquota" "prjquota" ];
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
|
@@ -1,7 +1,9 @@
|
||||
{ ... }@passedArgs:
|
||||
let
|
||||
lib = passedArgs.lib or passedArgs.pkgs.lib;
|
||||
args = passedArgs // { inherit lib vaculib; };
|
||||
args = passedArgs // {
|
||||
inherit lib vaculib;
|
||||
};
|
||||
directoryListing = builtins.removeAttrs (builtins.readDir ./.) [ "default.nix" ];
|
||||
filePaths = lib.mapAttrsToList (
|
||||
k: v:
|
||||
|
Reference in New Issue
Block a user