resolve merge artifacts and remove old code
This commit is contained in:
parent
963d52399e
commit
97096a423f
10 changed files with 0 additions and 202 deletions
|
@ -1,21 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
let
|
|
||||||
inherit (lib.lists) any count;
|
|
||||||
inherit (lib.attrsets) filterAttrs listToAttrs mapAttrs' mapAttrsToList;
|
|
||||||
in rec
|
|
||||||
{
|
|
||||||
attrsToList = attrs:
|
|
||||||
mapAttrsToList (name: value: { inherit name value; }) attrs;
|
|
||||||
|
|
||||||
mapFilterAttrs = pred: f: attrs:
|
|
||||||
filterAttrs pred (mapAttrs' f attrs);
|
|
||||||
|
|
||||||
getAttrs' = values: f:
|
|
||||||
listToAttrs (map f values);
|
|
||||||
|
|
||||||
anyAttrs = pred: attrs:
|
|
||||||
any (attr: pred attr.name attr.value) (attrsToList attrs);
|
|
||||||
|
|
||||||
countAttrs = pred: attrs:
|
|
||||||
count (attr: pred attr.name attr.value) (attrsToList attrs);
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
{ inputs, lib, pkgs, ... }:
|
|
||||||
let
|
|
||||||
inherit (lib.attrsets) attrValues;
|
|
||||||
inherit (lib.fixedPoints) makeExtensible;
|
|
||||||
inherit (lib.lists) foldr;
|
|
||||||
inherit (modules) mapModules;
|
|
||||||
|
|
||||||
modules = import ./modules.nix {
|
|
||||||
inherit lib;
|
|
||||||
|
|
||||||
self.attrs = import ./attrs.nix {
|
|
||||||
inherit lib;
|
|
||||||
|
|
||||||
self = {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mylib = makeExtensible (self:
|
|
||||||
mapModules ./. (file: import file { inherit self lib pkgs inputs; })
|
|
||||||
);
|
|
||||||
in
|
|
||||||
mylib.extend (self: super: foldr (a: b: a // b) {} (attrValues super))
|
|
|
@ -1,52 +0,0 @@
|
||||||
{ lib, self, ... }:
|
|
||||||
let
|
|
||||||
inherit (builtins) attrValues readDir pathExists concatLists replaceStrings listToAttrs;
|
|
||||||
inherit (lib.attrsets) mapAttrsToList filterAttrs nameValuePair;
|
|
||||||
inherit (lib.strings) hasPrefix hasSuffix removeSuffix removePrefix;
|
|
||||||
inherit (lib.trivial) id;
|
|
||||||
inherit (lib) flatten;
|
|
||||||
inherit (self.attrs) mapFilterAttrs;
|
|
||||||
in rec
|
|
||||||
{
|
|
||||||
mapModules = dir: fn:
|
|
||||||
mapFilterAttrs (n: v: v != null && !(hasPrefix "_" n)) (n: v: let path = "${toString dir}/${n}"; in
|
|
||||||
if v == "directory" && pathExists "${path}/default.nix"
|
|
||||||
then nameValuePair n (fn path)
|
|
||||||
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n && !(hasPrefix "_" n)
|
|
||||||
then nameValuePair (removeSuffix ".nix" n) (fn path)
|
|
||||||
else nameValuePair "" null
|
|
||||||
) (readDir dir);
|
|
||||||
|
|
||||||
mapModules' = dir: fn: attrValues (mapModules dir fn);
|
|
||||||
|
|
||||||
mapModulesRec = dir: fn:
|
|
||||||
mapFilterAttrs (n: v: v != null && !(hasPrefix "_" n)) (n: v: let path = "${toString dir}/${n}"; in
|
|
||||||
if v == "directory" && pathExists "${path}/default.nix"
|
|
||||||
then nameValuePair n (mapModulesRec path fn)
|
|
||||||
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n
|
|
||||||
then nameValuePair (removeSuffix ".nix" n) (fn path)
|
|
||||||
else nameValuePair "" null
|
|
||||||
) (readDir dir);
|
|
||||||
|
|
||||||
mapModulesRec' = dir: fn: let
|
|
||||||
dirs = mapAttrsToList (k: _: "${dir}/${k}") (filterAttrs (n: v: v == "directory" && !(hasPrefix "_" n)) (readDir dir));
|
|
||||||
files = attrValues (mapModules dir id);
|
|
||||||
paths = files ++ concatLists (map (d: mapModulesRec' d id) dirs);
|
|
||||||
in
|
|
||||||
map fn paths;
|
|
||||||
|
|
||||||
readNixosModules = dir: fn: filterAttrs (name: value: value != null && !(hasPrefix "_" name)) (listToAttrs (flatten (readDirRecursive fn dir "")));
|
|
||||||
|
|
||||||
readDirRecursive = fn: root: dir: mapAttrsToList (name: type:
|
|
||||||
if type == "directory" && pathExists "${root}/${dir}/${name}/default.nix"
|
|
||||||
then [
|
|
||||||
(nameValuePair "${replaceStrings ["/"] ["_"] (removePrefix "/" dir)}_${name}" (fn "${root}/${dir}/${name}/default.nix"))
|
|
||||||
(readDirRecursive fn root "${dir}/${name}")
|
|
||||||
]
|
|
||||||
else if type == "directory"
|
|
||||||
then readDirRecursive fn root "${dir}/${name}"
|
|
||||||
else if type == "regular" && name != "default.nix" && hasSuffix ".nix" name
|
|
||||||
then nameValuePair "${replaceStrings ["/"] ["_"] (removePrefix "/" dir)}_${removeSuffix ".nix" name}" (fn "${root}/${dir}/${name}")
|
|
||||||
else nameValuePair "" null
|
|
||||||
) (readDir "${root}/${dir}");
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
{ inputs, lib, pkgs, self, ... }: let
|
|
||||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
|
||||||
inherit (builtins) baseNameOf elem map listToAttrs pathExists;
|
|
||||||
inherit (lib) filterAttrs nameValuePair attrNames;
|
|
||||||
inherit (lib.modules) mkDefault mkIf;
|
|
||||||
inherit (lib.strings) removeSuffix;
|
|
||||||
inherit (self.modules) mapModules mapModulesRec';
|
|
||||||
inherit (self) mkSysUser;
|
|
||||||
in rec
|
|
||||||
{
|
|
||||||
mkHost = path: attrs @ {system ? "x86_64-linux", ...}:
|
|
||||||
nixosSystem {
|
|
||||||
inherit system;
|
|
||||||
|
|
||||||
specialArgs = {inherit lib inputs system; };
|
|
||||||
|
|
||||||
modules = let
|
|
||||||
stateVersion = "23.11";
|
|
||||||
users = if (pathExists "${path}/users") then attrNames (mapModules "${path}/users" (p: p)) else [];
|
|
||||||
in [
|
|
||||||
inputs.nixos-boot.nixosModules.default
|
|
||||||
({ ... }: {
|
|
||||||
nixpkgs.pkgs = pkgs;
|
|
||||||
|
|
||||||
networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf path));
|
|
||||||
|
|
||||||
system = {
|
|
||||||
inherit stateVersion;
|
|
||||||
configurationRevision = mkIf (self ? rev) self.rev;
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
inputs.home-manager.nixosModules.home-manager
|
|
||||||
"${path}/hardware.nix"
|
|
||||||
]
|
|
||||||
++ (mapModulesRec' ../modules/system import);
|
|
||||||
|
|
||||||
users = {
|
|
||||||
mutableUsers = true; # Set this to false when I get sops with passwords set up properly
|
|
||||||
users = mkIf (pathExists "${path}/users") (mapModules "${path}/users" mkSysUser);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
(filterAttrs (n: v: !elem n ["system"]) attrs)
|
|
||||||
(import path)
|
|
||||||
(args@{ inputs, lib, pkgs, config, options, ... }: {
|
|
||||||
imports = mapModulesRec' ../modules/home (file: (import file (args // { user = "root"; })));
|
|
||||||
})
|
|
||||||
({...}: {
|
|
||||||
imports = [];
|
|
||||||
|
|
||||||
config = {
|
|
||||||
home-manager = {
|
|
||||||
backupFileExtension = "bak";
|
|
||||||
useGlobalPkgs = true;
|
|
||||||
sharedModules = [
|
|
||||||
inputs.plasma-manager.homeManagerModules.plasma-manager
|
|
||||||
];
|
|
||||||
|
|
||||||
users = listToAttrs (map (user: (nameValuePair user { home = { inherit stateVersion; }; })) (users ++ ["root"]));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]
|
|
||||||
++ (map (user: (args@{ inputs, lib, pkgs, config, options, ... }: {
|
|
||||||
imports = mapModulesRec' ../modules/home (file: (import file (args // { inherit user; })));
|
|
||||||
|
|
||||||
config.modules.${user} = (import "${path}/users/${user}/default.nix" args);
|
|
||||||
})) users);
|
|
||||||
};
|
|
||||||
|
|
||||||
mapHosts = dir: attrs @ {system ? system, ...}:
|
|
||||||
mapModules dir (hostPath: mkHost hostPath attrs);
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
{lib, ...}: let
|
|
||||||
inherit (lib.options) mkOption;
|
|
||||||
in {
|
|
||||||
mkOpt = type: default: mkOption {inherit type default;};
|
|
||||||
|
|
||||||
mkOpt' = type: default: description:
|
|
||||||
mkOption {inherit type default description;};
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
{ lib, ... }: let
|
|
||||||
inherit (builtins) baseNameOf;
|
|
||||||
inherit (lib.attrsets) filterAttrs;
|
|
||||||
inherit (lib.strings) removeSuffix;
|
|
||||||
inherit (lib.my) mapModulesRec';
|
|
||||||
in rec
|
|
||||||
{
|
|
||||||
mkSysUser = path: let
|
|
||||||
name = removeSuffix ".nix" (baseNameOf path);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit name;
|
|
||||||
isNormalUser = true;
|
|
||||||
initialPassword = "kaas";
|
|
||||||
home = "/home/${name}";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
|
|
||||||
mkHmUser = path: {stateVersion, ...}:
|
|
||||||
{
|
|
||||||
home = {
|
|
||||||
inherit stateVersion;
|
|
||||||
sessionPath = [ "$XDG_BIN_HOME" "$PATH" ]; # Pretty sure I don't need this.
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue