Run linter+formatter.

This commit is contained in:
Kevin Baensch 2023-09-11 21:20:14 +02:00
parent 8fd1b6c982
commit e2330f01fc
Signed by: derped
GPG key ID: C0F1D326C7626543
16 changed files with 58 additions and 54 deletions

View file

@ -11,7 +11,8 @@
fi fi
exit 0; exit 0;
''); '');
in (pkgs.writeText "rofi.rasi" '' in
pkgs.writeText "rofi.rasi" ''
configuration { configuration {
modi: "combi,window,drun,ssh,tabFinder:${tabMode}"; modi: "combi,window,drun,ssh,tabFinder:${tabMode}";
font: "hack 10"; font: "hack 10";
@ -20,4 +21,4 @@ in (pkgs.writeText "rofi.rasi" ''
show-icons: true; show-icons: true;
} }
@theme "solarized" @theme "solarized"
'') ''

View file

@ -4,10 +4,10 @@
... ...
}: }:
with lib; let with lib; let
networkD = config.machine.networkD; inherit (config.machine) networkD;
in { in {
networking = { networking = {
hostName = config.machine.hostName; inherit (config.machine) hostName;
useNetworkd = networkD.enable; useNetworkd = networkD.enable;
useDHCP = !networkD.enable; useDHCP = !networkD.enable;
dhcpcd.enable = !networkD.enable; dhcpcd.enable = !networkD.enable;

View file

@ -9,13 +9,13 @@ with lib; let
withDocker = config.virtualisation.docker.enable; withDocker = config.virtualisation.docker.enable;
withPodman = config.virtualisation.podman.enable; withPodman = config.virtualisation.podman.enable;
administrators = user: { administrators = user: {
name = user.name; inherit (user) name;
value = let value = let
cfg = config.services; cfg = config.services;
passPath = config.sops.secrets."users/${user.name}/password".path; passPath = config.sops.secrets."users/${user.name}/password".path;
in { in {
isNormalUser = true; isNormalUser = true;
name = user.name; inherit (user) name;
uid = user.id; uid = user.id;
subUidRanges = optional withPodman { subUidRanges = optional withPodman {
startUid = 100000; startUid = 100000;
@ -41,9 +41,9 @@ with lib; let
}; };
mkusergroup = user: { mkusergroup = user: {
name = user.name; inherit (user) name;
value = { value = {
name = user.name; inherit (user) name;
gid = user.id; gid = user.id;
members = [user.name]; members = [user.name];
}; };

View file

@ -6,7 +6,7 @@ with lib; let
# hostName and secretPtah can be set with -I hostName=$HOSTNAME and -I secretPath=$SECRETPATH respectively # hostName and secretPtah can be set with -I hostName=$HOSTNAME and -I secretPath=$SECRETPATH respectively
# , defaults to the contents of /secret/hostName # , defaults to the contents of /secret/hostName
secretPath = secretPath =
fn.ifelse ((tryEval (toString <secretPath>)).value != false) fn.ifelse (tryEval (toString <secretPath>)).value
(toString <secretPath>) (toString <secretPath>)
(toString /secret); (toString /secret);
hostName = hostName =

View file

@ -6,12 +6,12 @@
nixpkgs-unstable.url = "github:/NixOS/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:/NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable";
alejandra = { alejandra = {
url = github:kamadorueda/alejandra/3.0.0; url = "github:kamadorueda/alejandra/3.0.0";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
mailserver.url = "gitlab:/simple-nixos-mailserver/nixos-mailserver"; mailserver.url = "gitlab:/simple-nixos-mailserver/nixos-mailserver";
sops-nix = { sops-nix = {
url = github:Mic92/sops-nix; url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
@ -23,15 +23,17 @@
sops-nix, sops-nix,
... ...
} @ attrs: let } @ attrs: let
lib = nixpkgs.lib; inherit (nixpkgs) lib;
fn = import ./fn.nix {inherit lib;}; fn = import ./fn.nix {inherit lib;};
mappedFormatter = builtins.mapAttrs (arch: packages: packages.default) alejandra.packages; mappedFormatter = builtins.mapAttrs (arch: packages: packages.default) alejandra.packages;
mappedApps = builtins.mapAttrs (_arch: packages: { mappedApps =
builtins.mapAttrs (_arch: packages: {
"lint" = { "lint" = {
type = "app"; type = "app";
program = "${packages.statix}/bin/statix"; program = "${packages.statix}/bin/statix";
}; };
}) nixpkgs.legacyPackages; })
nixpkgs.legacyPackages;
system = "x86_64-linux"; system = "x86_64-linux";
machineList = fn.lst { machineList = fn.lst {
p = toString ./machines; p = toString ./machines;
@ -54,14 +56,14 @@
name = machine; name = machine;
value = let value = let
machinePath = lib.concatStringsSep "/" [(toString ./.) "machines" machine]; machinePath = lib.concatStringsSep "/" [(toString ./.) "machines" machine];
machineFiles = lib.filter (name: lib.strings.hasSuffix ".nix" name) (fn.lst { machineFiles = lib.filter (lib.strings.hasSuffix ".nix") (fn.lst {
p = machinePath; p = machinePath;
b = true; b = true;
}); });
in in
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs = attrs // {fn = fn;}; specialArgs = attrs // {inherit fn;};
modules = modules =
[ [
(toString ./options/machine.nix) (toString ./options/machine.nix)

16
fn.nix
View file

@ -21,17 +21,17 @@ with lib; rec {
(filterAttrs (n: v: v == t) (filterAttrs (n: v: v == t)
(readDir p))) (readDir p)))
(v: ((optionalString b "${p}/") + v))); (v: ((optionalString b "${p}/") + v)));
lsf = p: (lst {p = p;}); lsf = p: (lst {inherit p;});
lsd = p: (lst { lsd = p: (lst {
p = p; inherit p;
t = "directory"; t = "directory";
b = true; b = true;
}); });
lsfRec = p: b: lsfRec = p: b:
flatten ((map (np: lsfRec np b) (lsd p)) flatten ((map (np: lsfRec np b) (lsd p))
++ (lst { ++ (lst {
p = p; inherit p;
b = b; inherit b;
})); }));
hasAttrs = aList: d: (map hasAttrs = aList: d: (map
(a: (ifelse (isList a) (a: (ifelse (isList a)
@ -53,11 +53,11 @@ with lib; rec {
(meetsConDo cond do t)); (meetsConDo cond do t));
deps = p: deps = p:
ifelse (isAttrs p) ( ifelse (isAttrs p) (
filter (p: isAttrs p) filter isAttrs
(p.buildInputs ++ p.nativeBuildInputs ++ p.propagatedBuildInputs ++ p.propagatedNativeBuildInputs) (p.buildInputs ++ p.nativeBuildInputs ++ p.propagatedBuildInputs ++ p.propagatedNativeBuildInputs)
) []; ) [];
importFilter = l: p: filter (n: elem (nameFromURL (toString n) ".") l) p; importFilter = l: filter (n: elem (nameFromURL (toString n) ".") l);
depsRec = ld: ifelse (ld == []) [] ((toList ld) ++ (depsRec (lists.unique (lists.flatten (map (d: deps d) (toList ld)))))); depsRec = ld: ifelse (ld == []) [] ((toList ld) ++ (depsRec (lists.unique (lists.flatten (map deps (toList ld))))));
isBroken = p: isBroken = p:
meetsConDo (s: ((hasAttrByPath s.path p) && (s.check (getAttrFromPath s.path p)))) (s: s.msg) meetsConDo (s: ((hasAttrByPath s.path p) && (s.check (getAttrFromPath s.path p)))) (s: s.msg)
[ [
@ -113,7 +113,7 @@ with lib; rec {
makeOptionTypeList = path: ( makeOptionTypeList = path: (
lists.forEach lists.forEach
# get a list of all files ending in .nix in path # get a list of all files ending in .nix in path
(filter (filePath: hasSuffix ".nix" filePath) (filter (hasSuffix ".nix")
(lsfRec path true)) (lsfRec path true))
# remove leading path and trailing ".nix", replace every slash with "::" # remove leading path and trailing ".nix", replace every slash with "::"
(replaceStrings ["${path}/" "/" ".nix"] ["" "::" ""]) (replaceStrings ["${path}/" "/" ".nix"] ["" "::" ""])

View file

@ -200,7 +200,7 @@ with lib; let
mkMode = map (v: ":mode ${v}"); mkMode = map (v: ":mode ${v}");
mkBind = mkBindHelper "bind" ""; mkBind = mkBindHelper "bind" "";
mkBindLocal = bs: let mkBindLocal = bs: let
mkMap = n: v: mkBindHelper "bind" ":map ${n}" v; mkMap = n: mkBindHelper "bind" ":map ${n}";
in in
flatten (mapAttrsToList mkMap bs); flatten (mapAttrsToList mkMap bs);
mkBindKeyMap = mkBindHelper "bind-keymap" ""; mkBindKeyMap = mkBindHelper "bind-keymap" "";
@ -430,21 +430,23 @@ in {
++ optional hasDiminish epkgs.diminish ++ optional hasDiminish epkgs.diminish
++ optional hasChords epkgs.use-package-chords ++ optional hasChords epkgs.use-package-chords
++ ( ++ (
concatMap (v: getPkg (v.package)) concatMap (v: getPkg v.package)
(builtins.attrValues cfg.usePackage) (builtins.attrValues cfg.usePackage)
); );
# use lucid as toolkit; emacs will otherwise crash quite frequently when run in daemon mode # use lucid as toolkit; emacs will otherwise crash quite frequently when run in daemon mode
# https://gitlab.gnome.org/GNOME/gtk/issues/221 # https://gitlab.gnome.org/GNOME/gtk/issues/221
machine.pkgsets.emacs.pkgwrap = let machine.pkgsets.emacs.pkgwrap = let
emacsWithPackages = inherit
(pkgs.emacsPackagesFor ((pkgs.emacsPackagesFor
(pkgs.emacs.override { (pkgs.emacs.override {
withGTK2 = false; withGTK2 = false;
withGTK3 = false; withGTK3 = false;
})) })))
.emacsWithPackages; emacsWithPackages
in (emacsWithPackages config.machine.pkgsets.emacs.pkgs); ;
in
emacsWithPackages config.machine.pkgsets.emacs.pkgs;
environment.systemPackages = [ environment.systemPackages = [
((pkgs.emacsPackagesFor config.machine.pkgsets.emacs.pkgwrap).trivialBuild { ((pkgs.emacsPackagesFor config.machine.pkgsets.emacs.pkgwrap).trivialBuild {

View file

@ -69,6 +69,6 @@ buildPythonPackage rec {
description = "GNU Mailman, a mailing list management system"; description = "GNU Mailman, a mailing list management system";
license = licenses.gpl3; license = licenses.gpl3;
maintainers = with maintainers; []; maintainers = with maintainers; [];
homepage = http://list.org/; homepage = "http://list.org/";
}; };
} }

View file

@ -7,7 +7,7 @@
nixpkgs-git, nixpkgs-git,
... ...
}: let }: let
callPackage = pkgs.callPackage; inherit (pkgs) callPackage;
in { in {
nixpkgs = { nixpkgs = {
config = { config = {

View file

@ -28,7 +28,7 @@
]; ];
} }
// {src = nightly.rust-src;}; // {src = nightly.rust-src;};
cargo = nightly.cargo; inherit (nightly) cargo;
}; };
rustPNightly = stablepkgs.recurseIntoAttrs (stablepkgs.makeRustPlatform { rustPNightly = stablepkgs.recurseIntoAttrs (stablepkgs.makeRustPlatform {
inherit (rustNightly) rustc cargo; inherit (rustNightly) rustc cargo;

View file

@ -8,7 +8,7 @@ with lib;
services = { services = {
gitea = let gitea = let
cfg = config.machine; cfg = config.machine;
domain = (findFirst (s: s.service == "gitea") cfg cfg.vHosts).domain; inherit ((findFirst (s: s.service == "gitea") cfg cfg.vHosts)) domain;
in { in {
enable = true; enable = true;
user = "git"; user = "git";

View file

@ -25,7 +25,7 @@ in
services = let services = let
cfg = config.machine; cfg = config.machine;
domain = (findFirst (s: s.service == "hydra") cfg cfg.vHosts).domain; inherit ((findFirst (s: s.service == "hydra") cfg cfg.vHosts)) domain;
in { in {
hydra = { hydra = {
enable = true; enable = true;

View file

@ -14,7 +14,7 @@ with lib;
// mkIf (elem "mailserver" config.machine.services) { // mkIf (elem "mailserver" config.machine.services) {
mailserver = let mailserver = let
cfg = config.machine; cfg = config.machine;
domain = cfg.domain; inherit (cfg) domain;
fdomain = (findFirst (s: s.service == "mail") cfg cfg.vHosts).domain; fdomain = (findFirst (s: s.service == "mail") cfg cfg.vHosts).domain;
mkFqdnAlias = name: ["${name}@${domain}" "${name}@${fdomain}"]; mkFqdnAlias = name: ["${name}@${domain}" "${name}@${fdomain}"];
mkExDomAlias = name: (map (exDom: "${name}@${exDom}") cfg.extraDomains); mkExDomAlias = name: (map (exDom: "${name}@${exDom}") cfg.extraDomains);

View file

@ -9,7 +9,7 @@ with lib;
mkIf (elem "nextcloud" config.machine.services) { mkIf (elem "nextcloud" config.machine.services) {
services = let services = let
cfg = config.machine; cfg = config.machine;
domain = (findFirst (s: s.service == "nextcloud") cfg cfg.vHosts).domain; inherit ((findFirst (s: s.service == "nextcloud") cfg cfg.vHosts)) domain;
in { in {
nextcloud = { nextcloud = {
enable = true; enable = true;

View file

@ -6,7 +6,7 @@
... ...
}: }:
with lib; with lib;
if (config.services.nextcloud.enable == true) if config.services.nextcloud.enable
then then
{ {
vHost = { vHost = {

View file

@ -31,13 +31,12 @@ with lib;
}; };
# Add public keys to /etc/ssh/authorized_keys.d # Add public keys to /etc/ssh/authorized_keys.d
# This replaces users.users.*.openssh.authorizedKeys.* # This replaces users.users.*.openssh.authorizedKeys.*
sops.secrets = ( sops.secrets =
fn.sopsHelper fn.sopsHelper
(user: "users/${user.name}/publicKey") (user: "users/${user.name}/publicKey")
config.machine.administrators config.machine.administrators
(user: { (user: {
path = "/etc/ssh/authorized_keys.d/${user.name}"; path = "/etc/ssh/authorized_keys.d/${user.name}";
mode = "444"; mode = "444";
}) });
);
} }