mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
I don't know if i like this
This commit is contained in:
parent
c6a9144ffe
commit
1b62d16ddc
63 changed files with 369 additions and 294 deletions
30
devShells/_default.nix
Normal file
30
devShells/_default.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{ inputs', ... }:
|
||||||
|
let
|
||||||
|
inherit (inputs'.unstable) lib;
|
||||||
|
pkgs = inputs'.unstable.legacyPackages;
|
||||||
|
in
|
||||||
|
lib.pipe ./. [
|
||||||
|
builtins.readDir
|
||||||
|
builtins.attrNames
|
||||||
|
(builtins.filter (x: x != "_default.nix"))
|
||||||
|
(map (
|
||||||
|
x:
|
||||||
|
let
|
||||||
|
fullPath = ./. + "/${x}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
${lib.removeSuffix ".nix" x} = lib.callPackageWith (
|
||||||
|
pkgs
|
||||||
|
// pkgs.xorg
|
||||||
|
// {
|
||||||
|
inherit inputs';
|
||||||
|
self' = inputs'.self;
|
||||||
|
# npins sources if i ever use them
|
||||||
|
# sources = lib.mapAttrs (_: pkgs.npins.mkSource) (lib.importJSON "${self}/packages/sources.json").pins;
|
||||||
|
}
|
||||||
|
) fullPath { };
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
|
lib.mergeAttrsList
|
||||||
|
]
|
||||||
1
devShells/default.nix
Normal file
1
devShells/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ mkShellNoCC, sops }: mkShellNoCC { packages = [ sops ]; }
|
||||||
18
diskoConfigurations/_default.nix
Normal file
18
diskoConfigurations/_default.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
inputs:
|
||||||
|
let
|
||||||
|
inherit (inputs.unstable) lib;
|
||||||
|
in
|
||||||
|
lib.pipe ./. [
|
||||||
|
builtins.readDir
|
||||||
|
(lib.filterAttrs (n: v: v == "regular" && lib.hasSuffix ".nix" n && n != "_default.nix"))
|
||||||
|
builtins.attrNames
|
||||||
|
(map (x: {
|
||||||
|
name = lib.pipe x [
|
||||||
|
(lib.removeSuffix (toString ./.))
|
||||||
|
(lib.removeSuffix ".nix")
|
||||||
|
(x: "disko-${x}")
|
||||||
|
];
|
||||||
|
value.disko.devices = import "${./.}/${x}" lib;
|
||||||
|
}))
|
||||||
|
builtins.listToAttrs
|
||||||
|
]
|
||||||
34
flake.lock
generated
34
flake.lock
generated
|
|
@ -241,11 +241,11 @@
|
||||||
},
|
},
|
||||||
"master": {
|
"master": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1737083351,
|
"lastModified": 1737155754,
|
||||||
"narHash": "sha256-hCddtSuk6m6XROmdOC0te0j2sLeUr28QIzNRk0qF1as=",
|
"narHash": "sha256-dIjCfIEkHUQI8WMkHLhAXyrYsk2RNqqIFAXFQdwTQn0=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0993fc268872148cebcd1fac8660a8b8ced49542",
|
"rev": "7d5856e1fbacca23cca90549b81e5aacbc76e9c7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -570,6 +570,7 @@
|
||||||
"spicetify-nix": "spicetify-nix",
|
"spicetify-nix": "spicetify-nix",
|
||||||
"stable": "stable",
|
"stable": "stable",
|
||||||
"suckless": "suckless",
|
"suckless": "suckless",
|
||||||
|
"systems": "systems",
|
||||||
"unstable": "unstable"
|
"unstable": "unstable"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -619,11 +620,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1736808430,
|
"lastModified": 1737107480,
|
||||||
"narHash": "sha256-wlgdf/n7bJMLBheqt1jmPoxJFrUP6FByKQFXuM9YvIk=",
|
"narHash": "sha256-GXUE9+FgxoZU8v0p6ilBJ8NH7k8nKmZjp/7dmMrCv3o=",
|
||||||
"owner": "mic92",
|
"owner": "mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "553c7cb22fed19fd60eb310423fdc93045c51ba8",
|
"rev": "4c4fb93f18b9072c6fa1986221f9a3d7bf1fe4b6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -689,13 +690,28 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"unstable": {
|
"unstable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1736883708,
|
"lastModified": 1737062831,
|
||||||
"narHash": "sha256-uQ+NQ0/xYU0N1CnXsa2zghgNaOPxWpMJXSUJJ9W7140=",
|
"narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "eb62e6aa39ea67e0b8018ba8ea077efe65807dc8",
|
"rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
37
flake.nix
37
flake.nix
|
|
@ -94,8 +94,41 @@
|
||||||
repo = "reboot-bot";
|
repo = "reboot-bot";
|
||||||
inputs.nixpkgs.follows = "unstable";
|
inputs.nixpkgs.follows = "unstable";
|
||||||
};
|
};
|
||||||
|
systems = {
|
||||||
|
type = "github";
|
||||||
|
owner = "nix-systems";
|
||||||
|
repo = "default";
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
outputs =
|
||||||
outputs = x: import ./outputs.nix x;
|
inputs:
|
||||||
|
let
|
||||||
|
inherit (inputs.unstable) lib;
|
||||||
|
myLib = import (./. + /lib/_default.nix) inputs;
|
||||||
|
in
|
||||||
|
lib.pipe ./. [
|
||||||
|
builtins.readDir
|
||||||
|
(lib.filterAttrs (n: v: v == "directory" && !lib.hasPrefix "." n))
|
||||||
|
(lib.flip (
|
||||||
|
system:
|
||||||
|
(builtins.mapAttrs (
|
||||||
|
n: _:
|
||||||
|
let
|
||||||
|
imported = import (./. + "/${n}/_default.nix");
|
||||||
|
in
|
||||||
|
if myLib.needsSystem n then
|
||||||
|
{
|
||||||
|
${system} = imported {
|
||||||
|
inputs' = myLib.constructInputs' system inputs;
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
imported inputs
|
||||||
|
))
|
||||||
|
))
|
||||||
|
(lib.flip map (import inputs.systems))
|
||||||
|
(lib.foldAttrs (l: r: if myLib.needsSystem l then l else l // r) { })
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
formatter/_default.nix
Normal file
1
formatter/_default.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ inputs', ... }: inputs'.self.packages.lint
|
||||||
139
lib/_default.nix
Normal file
139
lib/_default.nix
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
{
|
||||||
|
unstable,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}@inputs:
|
||||||
|
let
|
||||||
|
inherit (unstable) lib;
|
||||||
|
in
|
||||||
|
lib.fix (myLib: {
|
||||||
|
wrench = lib.flip lib.pipe;
|
||||||
|
|
||||||
|
needsSystem = lib.flip builtins.elem [
|
||||||
|
"defaultPackage"
|
||||||
|
"devShell"
|
||||||
|
"devShells"
|
||||||
|
"formatter"
|
||||||
|
"legacyPackages"
|
||||||
|
"packages"
|
||||||
|
];
|
||||||
|
|
||||||
|
constructInputs' =
|
||||||
|
system:
|
||||||
|
myLib.wrench [
|
||||||
|
(lib.filterAttrs (_: lib.isType "flake"))
|
||||||
|
(lib.mapAttrs (
|
||||||
|
_: lib.mapAttrs (name: value: if myLib.needsSystem name then value.${system} else value)
|
||||||
|
))
|
||||||
|
];
|
||||||
|
|
||||||
|
listNixFilesRecursive = myLib.wrench [
|
||||||
|
builtins.unsafeDiscardStringContext
|
||||||
|
lib.filesystem.listFilesRecursive
|
||||||
|
(builtins.filter (x: !lib.hasPrefix "_" (builtins.baseNameOf x) && lib.hasSuffix ".nix" x))
|
||||||
|
];
|
||||||
|
|
||||||
|
addSchizophreniaToModule =
|
||||||
|
x:
|
||||||
|
let
|
||||||
|
# the imported module
|
||||||
|
imported = import x;
|
||||||
|
in
|
||||||
|
/*
|
||||||
|
If the module isn't a function then
|
||||||
|
it doesn't need arguments and error
|
||||||
|
message locations will function correctly
|
||||||
|
*/
|
||||||
|
if !lib.isFunction imported then
|
||||||
|
x
|
||||||
|
else
|
||||||
|
let
|
||||||
|
# all arguments defined in the module
|
||||||
|
funcArgs = lib.functionArgs imported;
|
||||||
|
/*
|
||||||
|
The names of all arguments which will be
|
||||||
|
available to be inserted into the module arguments
|
||||||
|
*/
|
||||||
|
argNames = builtins.attrNames inputs ++ [
|
||||||
|
"inputs"
|
||||||
|
"inputs'"
|
||||||
|
"self'"
|
||||||
|
"_dir"
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
arguments to be passed minus
|
||||||
|
per system attributes
|
||||||
|
for example flake-parts-esque inputs'
|
||||||
|
*/
|
||||||
|
argsPre = {
|
||||||
|
inherit inputs self;
|
||||||
|
/*
|
||||||
|
_dir is the "self" derived
|
||||||
|
path to the directory containing the module
|
||||||
|
*/
|
||||||
|
_dir = builtins.dirOf x;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
arguments which will be inserted
|
||||||
|
set to the before per-system values
|
||||||
|
*/
|
||||||
|
providedArgs = lib.pipe funcArgs [
|
||||||
|
(lib.filterAttrs (n: _: builtins.elem n argNames))
|
||||||
|
(lib.mapAttrs (n: _: argsPre.${n} or { }))
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
arguments which the module system
|
||||||
|
not provided here. either to be
|
||||||
|
provided by the module system or invalid
|
||||||
|
*/
|
||||||
|
neededArgs = lib.filterAttrs (n: _: !builtins.elem n argNames) funcArgs;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
__functionArgs = neededArgs // {
|
||||||
|
/*
|
||||||
|
always require pkgs to be passed
|
||||||
|
to derive system from pkgs.stdenv.system
|
||||||
|
*/
|
||||||
|
pkgs = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
__functor =
|
||||||
|
/*
|
||||||
|
args is specialArgs + _module.args which are needed
|
||||||
|
and always pkgs
|
||||||
|
*/
|
||||||
|
_: args:
|
||||||
|
imported (
|
||||||
|
/*
|
||||||
|
take module system provided arguments
|
||||||
|
filter them so only the required ones are passed
|
||||||
|
*/
|
||||||
|
(lib.filterAttrs (n: _: neededArgs ? ${n}) args)
|
||||||
|
# add needed arguments
|
||||||
|
// (
|
||||||
|
providedArgs
|
||||||
|
# add system dependent arguments
|
||||||
|
// (
|
||||||
|
let
|
||||||
|
inputs' = myLib.constructInputs' args.pkgs.stdenv.system inputs;
|
||||||
|
|
||||||
|
actuallyAllArgs = inputs' // {
|
||||||
|
inherit inputs';
|
||||||
|
self' = inputs'.self;
|
||||||
|
inherit (inputs) self;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib.filterAttrs (n: _: providedArgs ? ${n}) actuallyAllArgs
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
# add _file to the final module attribute set
|
||||||
|
// {
|
||||||
|
_file = x;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
})
|
||||||
282
lib/default.nix
282
lib/default.nix
|
|
@ -1,282 +0,0 @@
|
||||||
inputs@{
|
|
||||||
unstable,
|
|
||||||
self,
|
|
||||||
disko,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (unstable) lib;
|
|
||||||
in
|
|
||||||
# Only good use case for rec
|
|
||||||
rec {
|
|
||||||
wrench = lib.flip lib.pipe;
|
|
||||||
|
|
||||||
needsSystem = lib.flip builtins.elem [
|
|
||||||
"defaultPackage"
|
|
||||||
"devShell"
|
|
||||||
"devShells"
|
|
||||||
"formatter"
|
|
||||||
"legacyPackages"
|
|
||||||
"packages"
|
|
||||||
];
|
|
||||||
|
|
||||||
constructInputs' =
|
|
||||||
system:
|
|
||||||
wrench [
|
|
||||||
(lib.filterAttrs (_: lib.isType "flake"))
|
|
||||||
(lib.mapAttrs (_: lib.mapAttrs (name: value: if needsSystem name then value.${system} else value)))
|
|
||||||
];
|
|
||||||
|
|
||||||
listNixFilesRecursive = wrench [
|
|
||||||
builtins.unsafeDiscardStringContext
|
|
||||||
lib.filesystem.listFilesRecursive
|
|
||||||
(builtins.filter (x: !lib.hasPrefix "_" (builtins.baseNameOf x) && lib.hasSuffix ".nix" x))
|
|
||||||
];
|
|
||||||
|
|
||||||
mkModules =
|
|
||||||
path:
|
|
||||||
lib.pipe path [
|
|
||||||
listNixFilesRecursive
|
|
||||||
(map (name: {
|
|
||||||
name = lib.pipe name [
|
|
||||||
(lib.removeSuffix ".nix")
|
|
||||||
(lib.removePrefix "${path}/")
|
|
||||||
];
|
|
||||||
value = addSchizophreniaToModule name;
|
|
||||||
}))
|
|
||||||
builtins.listToAttrs
|
|
||||||
];
|
|
||||||
|
|
||||||
addSchizophreniaToModule =
|
|
||||||
x:
|
|
||||||
let
|
|
||||||
# the imported module
|
|
||||||
imported = import x;
|
|
||||||
in
|
|
||||||
/*
|
|
||||||
If the module isn't a function then
|
|
||||||
it doesn't need arguments and error
|
|
||||||
message locations will function correctly
|
|
||||||
*/
|
|
||||||
if !lib.isFunction imported then
|
|
||||||
x
|
|
||||||
else
|
|
||||||
let
|
|
||||||
# all arguments defined in the module
|
|
||||||
funcArgs = lib.functionArgs imported;
|
|
||||||
/*
|
|
||||||
The names of all arguments which will be
|
|
||||||
available to be inserted into the module arguments
|
|
||||||
*/
|
|
||||||
argNames = builtins.attrNames inputs ++ [
|
|
||||||
"inputs"
|
|
||||||
"inputs'"
|
|
||||||
"self'"
|
|
||||||
"_dir"
|
|
||||||
];
|
|
||||||
|
|
||||||
/*
|
|
||||||
arguments to be passed minus
|
|
||||||
per system attributes
|
|
||||||
for example flake-parts-esque inputs'
|
|
||||||
*/
|
|
||||||
argsPre = {
|
|
||||||
inherit inputs self;
|
|
||||||
/*
|
|
||||||
_dir is the "self" derived
|
|
||||||
path to the directory containing the module
|
|
||||||
*/
|
|
||||||
_dir = builtins.dirOf x;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
arguments which will be inserted
|
|
||||||
set to the before per-system values
|
|
||||||
*/
|
|
||||||
providedArgs = lib.pipe funcArgs [
|
|
||||||
(lib.filterAttrs (n: _: builtins.elem n argNames))
|
|
||||||
(lib.mapAttrs (n: _: argsPre.${n} or { }))
|
|
||||||
];
|
|
||||||
|
|
||||||
/*
|
|
||||||
arguments which the module system
|
|
||||||
not provided here. either to be
|
|
||||||
provided by the module system or invalid
|
|
||||||
*/
|
|
||||||
neededArgs = lib.filterAttrs (n: _: !builtins.elem n argNames) funcArgs;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
__functionArgs = neededArgs // {
|
|
||||||
/*
|
|
||||||
always require pkgs to be passed
|
|
||||||
to derive system from pkgs.stdenv.system
|
|
||||||
*/
|
|
||||||
pkgs = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
__functor =
|
|
||||||
/*
|
|
||||||
args is specialArgs + _module.args which are needed
|
|
||||||
and always pkgs
|
|
||||||
*/
|
|
||||||
_: args:
|
|
||||||
imported (
|
|
||||||
/*
|
|
||||||
take module system provided arguments
|
|
||||||
filter them so only the required ones are passed
|
|
||||||
*/
|
|
||||||
(lib.filterAttrs (n: _: neededArgs ? ${n}) args)
|
|
||||||
# add needed arguments
|
|
||||||
// (
|
|
||||||
providedArgs
|
|
||||||
# add system dependent arguments
|
|
||||||
// (
|
|
||||||
let
|
|
||||||
inputs' = constructInputs' args.pkgs.stdenv.system inputs;
|
|
||||||
|
|
||||||
actuallyAllArgs = inputs' // {
|
|
||||||
inherit inputs';
|
|
||||||
self' = inputs'.self;
|
|
||||||
inherit (inputs) self;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib.filterAttrs (n: _: providedArgs ? ${n}) actuallyAllArgs
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
# add _file to the final module attribute set
|
|
||||||
// {
|
|
||||||
_file = x;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
gerg-utils =
|
|
||||||
pkgsf: outputs:
|
|
||||||
lib.pipe
|
|
||||||
[
|
|
||||||
"x86_64-linux"
|
|
||||||
"aarch64-linux"
|
|
||||||
]
|
|
||||||
[
|
|
||||||
(map (
|
|
||||||
system:
|
|
||||||
builtins.mapAttrs (
|
|
||||||
name: value: if needsSystem name then { ${system} = value (pkgsf system); } else value
|
|
||||||
) outputs
|
|
||||||
))
|
|
||||||
(lib.foldAttrs lib.mergeAttrs { })
|
|
||||||
];
|
|
||||||
|
|
||||||
mkHosts = wrench [
|
|
||||||
builtins.readDir
|
|
||||||
(lib.filterAttrs (_: v: v == "directory"))
|
|
||||||
builtins.attrNames
|
|
||||||
(map (x: {
|
|
||||||
name = x;
|
|
||||||
value = lib.evalModules {
|
|
||||||
specialArgs.modulesPath = "${unstable}/nixos/modules";
|
|
||||||
modules = builtins.concatLists [
|
|
||||||
(builtins.attrValues self.nixosModules)
|
|
||||||
(map addSchizophreniaToModule (listNixFilesRecursive "${self}/hosts/${x}"))
|
|
||||||
(import "${unstable}/nixos/modules/module-list.nix")
|
|
||||||
(lib.optionals (self.diskoConfigurations ? "disko-${x}") [
|
|
||||||
self.diskoConfigurations."disko-${x}"
|
|
||||||
disko.nixosModules.default
|
|
||||||
])
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}))
|
|
||||||
builtins.listToAttrs
|
|
||||||
];
|
|
||||||
|
|
||||||
mkDisko =
|
|
||||||
path:
|
|
||||||
lib.pipe path [
|
|
||||||
builtins.readDir
|
|
||||||
(lib.filterAttrs (n: v: v == "regular" && lib.hasSuffix ".nix" n))
|
|
||||||
builtins.attrNames
|
|
||||||
(map (x: {
|
|
||||||
name = lib.pipe x [
|
|
||||||
(lib.removeSuffix path)
|
|
||||||
(lib.removeSuffix ".nix")
|
|
||||||
(x: "disko-${x}")
|
|
||||||
];
|
|
||||||
value.disko.devices = import "${path}/${x}" lib;
|
|
||||||
}))
|
|
||||||
builtins.listToAttrs
|
|
||||||
];
|
|
||||||
|
|
||||||
/*
|
|
||||||
/<name> -> packages named by directory
|
|
||||||
/<name>/call.nix -> callPackage override imported via import <file> pkgs
|
|
||||||
call.nix example
|
|
||||||
{python3Packages}: {
|
|
||||||
inherit (python3Packages) callPackage;
|
|
||||||
args = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/<name>/package.nix -> the package itself
|
|
||||||
/<name>/wrapper.nix:
|
|
||||||
a optional wrapper for the package
|
|
||||||
which is callPackage'd with the original package
|
|
||||||
as an argument named <name>-unwrapped
|
|
||||||
*/
|
|
||||||
mkPackages =
|
|
||||||
path: pkgs:
|
|
||||||
lib.pipe path [
|
|
||||||
builtins.readDir
|
|
||||||
(lib.filterAttrs (_: v: v == "directory"))
|
|
||||||
builtins.attrNames
|
|
||||||
(map (
|
|
||||||
n:
|
|
||||||
let
|
|
||||||
p = "${path}/${n}";
|
|
||||||
|
|
||||||
callPackage =
|
|
||||||
file: args:
|
|
||||||
let
|
|
||||||
defaultArgs =
|
|
||||||
pkgs
|
|
||||||
// pkgs.xorg
|
|
||||||
// (
|
|
||||||
let
|
|
||||||
inputs' = constructInputs' pkgs.stdenv.system inputs;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit inputs' inputs;
|
|
||||||
self' = inputs'.self;
|
|
||||||
inherit (inputs) self;
|
|
||||||
# npins sources if i ever use them
|
|
||||||
# sources = lib.mapAttrs (_: pkgs.npins.mkSource) (lib.importJSON "${self}/packages/sources.json").pins;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
_callPackage = lib.callPackageWith defaultArgs;
|
|
||||||
fullPath = "${p}/${file}.nix";
|
|
||||||
callPath = "${p}/call.nix";
|
|
||||||
in
|
|
||||||
assert lib.assertMsg (builtins.pathExists fullPath)
|
|
||||||
"File attempting to be callPackage'd '${fullPath}' does not exist";
|
|
||||||
|
|
||||||
if builtins.pathExists callPath then
|
|
||||||
let
|
|
||||||
x = _callPackage callPath { };
|
|
||||||
in
|
|
||||||
x.callPackage or _callPackage fullPath (x.args or defaultArgs // args)
|
|
||||||
|
|
||||||
else
|
|
||||||
_callPackage fullPath args;
|
|
||||||
in
|
|
||||||
|
|
||||||
if builtins.pathExists "${p}/wrapper.nix" then
|
|
||||||
# My distaste for rec grows ever stronger
|
|
||||||
let
|
|
||||||
set."${n}-unwrapped" = callPackage "package" { };
|
|
||||||
in
|
|
||||||
{ ${n} = callPackage "wrapper" set; } // set
|
|
||||||
else
|
|
||||||
{ ${n} = callPackage "package" { }; }
|
|
||||||
|
|
||||||
))
|
|
||||||
lib.mergeAttrsList
|
|
||||||
];
|
|
||||||
}
|
|
||||||
29
nixosConfigurations/_default.nix
Normal file
29
nixosConfigurations/_default.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
unstable,
|
||||||
|
disko,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
myLib = self.lib;
|
||||||
|
inherit (unstable) lib;
|
||||||
|
in
|
||||||
|
lib.pipe ./. [
|
||||||
|
builtins.readDir
|
||||||
|
(lib.filterAttrs (_: v: v == "directory"))
|
||||||
|
(builtins.mapAttrs (
|
||||||
|
x: _:
|
||||||
|
lib.evalModules {
|
||||||
|
specialArgs.modulesPath = "${unstable}/nixos/modules";
|
||||||
|
modules = builtins.concatLists [
|
||||||
|
(builtins.attrValues self.nixosModules)
|
||||||
|
(map myLib.addSchizophreniaToModule (myLib.listNixFilesRecursive (./. + "/${x}")))
|
||||||
|
(import "${unstable}/nixos/modules/module-list.nix")
|
||||||
|
(lib.optionals (self.diskoConfigurations ? "disko-${x}") [
|
||||||
|
self.diskoConfigurations."disko-${x}"
|
||||||
|
disko.nixosModules.default
|
||||||
|
])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
))
|
||||||
|
]
|
||||||
20
nixosModules/_default.nix
Normal file
20
nixosModules/_default.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
unstable,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
myLib = self.lib;
|
||||||
|
inherit (unstable) lib;
|
||||||
|
in
|
||||||
|
lib.pipe ./. [
|
||||||
|
myLib.listNixFilesRecursive
|
||||||
|
(map (name: {
|
||||||
|
name = lib.pipe name [
|
||||||
|
(lib.removeSuffix ".nix")
|
||||||
|
(lib.removePrefix "${./.}/")
|
||||||
|
];
|
||||||
|
value = myLib.addSchizophreniaToModule name;
|
||||||
|
}))
|
||||||
|
builtins.listToAttrs
|
||||||
|
]
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
options.local.sops.disable = lib.mkEnableOption "";
|
options.local.sops.disable = lib.mkEnableOption "";
|
||||||
config = lib.mkIf (!config.local.sops.disable) {
|
config = lib.mkIf (!config.local.sops.disable) {
|
||||||
sops = {
|
sops = {
|
||||||
defaultSopsFile = "${self'}/hosts/${config.networking.hostName}/secrets.yaml";
|
defaultSopsFile = "${self'}/nixosConfigurations/${config.networking.hostName}/secrets.yaml";
|
||||||
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
70
packages/_default.nix
Normal file
70
packages/_default.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
/<name> -> packages named by directory
|
||||||
|
/<name>/call.nix -> callPackage override imported via import <file> pkgs
|
||||||
|
call.nix example
|
||||||
|
{python3Packages}: {
|
||||||
|
inherit (python3Packages) callPackage;
|
||||||
|
args = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/<name>/package.nix -> the package itself
|
||||||
|
/<name>/wrapper.nix:
|
||||||
|
a optional wrapper for the package
|
||||||
|
which is callPackage'd with the original package
|
||||||
|
as an argument named <name>-unwrapped
|
||||||
|
*/
|
||||||
|
{ inputs', ... }:
|
||||||
|
let
|
||||||
|
inherit (inputs'.unstable) lib;
|
||||||
|
pkgs = inputs'.unstable.legacyPackages;
|
||||||
|
in
|
||||||
|
lib.pipe ./. [
|
||||||
|
builtins.readDir
|
||||||
|
(lib.filterAttrs (_: v: v == "directory"))
|
||||||
|
builtins.attrNames
|
||||||
|
(map (
|
||||||
|
n:
|
||||||
|
let
|
||||||
|
p = ./. + "/${n}";
|
||||||
|
|
||||||
|
callPackage =
|
||||||
|
file: args:
|
||||||
|
let
|
||||||
|
defaultArgs =
|
||||||
|
pkgs
|
||||||
|
// pkgs.xorg
|
||||||
|
// {
|
||||||
|
inherit inputs';
|
||||||
|
self' = inputs'.self;
|
||||||
|
# npins sources if i ever use them
|
||||||
|
# sources = lib.mapAttrs (_: pkgs.npins.mkSource) (lib.importJSON "${self}/packages/sources.json").pins;
|
||||||
|
};
|
||||||
|
_callPackage = lib.callPackageWith defaultArgs;
|
||||||
|
fullPath = p + "/${file}.nix";
|
||||||
|
callPath = p + /call.nix;
|
||||||
|
in
|
||||||
|
assert lib.assertMsg (builtins.pathExists fullPath)
|
||||||
|
"File attempting to be callPackage'd '${fullPath}' does not exist";
|
||||||
|
|
||||||
|
if builtins.pathExists callPath then
|
||||||
|
let
|
||||||
|
x = _callPackage callPath { };
|
||||||
|
in
|
||||||
|
x.callPackage or _callPackage fullPath (x.args or defaultArgs // args)
|
||||||
|
|
||||||
|
else
|
||||||
|
_callPackage fullPath args;
|
||||||
|
in
|
||||||
|
|
||||||
|
if builtins.pathExists (p + /wrapper.nix) then
|
||||||
|
# My distaste for rec grows ever stronger
|
||||||
|
let
|
||||||
|
set."${n}-unwrapped" = callPackage "package" { };
|
||||||
|
in
|
||||||
|
{ ${n} = callPackage "wrapper" set; } // set
|
||||||
|
else
|
||||||
|
{ ${n} = callPackage "package" { }; }
|
||||||
|
|
||||||
|
))
|
||||||
|
lib.mergeAttrsList
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue