grimm-nixos-laptop/fake_flake.nix

145 lines
3.9 KiB
Nix
Raw Normal View History

2024-05-07 23:31:41 +02:00
{
pkgs,
lib,
config,
system,
...
}:
2024-05-07 12:19:14 +02:00
let
nivSources = import ./nix/sources.nix;
asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}";
2024-05-07 13:41:59 +02:00
2024-05-08 21:50:08 +02:00
build_target =
let
env_host = builtins.getEnv "NIXOS_TARGET_HOST";
in
if env_host != "" then
env_host
else
builtins.replaceStrings [ "\n" ] [ "" ] (lib.toLower (builtins.readFile /proc/sys/kernel/hostname));
2024-05-08 20:00:00 +02:00
host_modules = {
2024-05-08 21:50:08 +02:00
grimmauld-nixos = [ ./specific/grimm-nixos-laptop/configuration.nix ];
2024-05-08 21:49:37 +02:00
grimmauld-nixos-server = [
./specific/grimmauld-nixos-server/configuration.nix
./modules
2024-05-08 21:49:37 +02:00
];
2024-05-08 20:00:00 +02:00
};
2024-05-07 13:41:59 +02:00
nixpkgs_patches = [
2024-05-11 11:37:59 +02:00
{
# xonsh update
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/305316.patch";
hash = "sha256-oUjCyA18RvIChTUwPqkO4+v2skTqLBYf2DMd+ADiGE8=";
}
2024-05-07 13:41:59 +02:00
];
2024-05-09 21:56:59 +02:00
# enable ccache for lix if ccache is enabled
enable_lix_ccache = true;
2024-05-07 12:19:14 +02:00
in
{
imports = [
"${nivSources.agenix}/modules/age.nix"
2024-05-08 21:49:37 +02:00
"${nivSources.nixos-mailserver}/default.nix"
"${nivSources.nixos-matrix-modules}/module.nix"
2024-05-12 09:46:41 +02:00
(import nivSources.authentik-nix).nixosModules.default
2024-05-08 21:49:37 +02:00
2024-05-08 21:50:08 +02:00
# fixme: ideally we'd not rely on the flake syntax to load the module
2024-05-08 21:49:37 +02:00
(builtins.getFlake (asGithubRef nivSources.chaotic)).nixosModules.default
# (builtins.getFlake (asGithubRef nivSources.nixos-matrix-modules)).nixosModules.default
# (builtins.getFlake "git+${nivSources.nixos-mailserver.repo}").nixosModules.default
2024-05-08 21:50:08 +02:00
] ++ lib.optionals (builtins.hasAttr build_target host_modules) host_modules.${build_target};
2024-05-07 12:19:14 +02:00
system.nixos = {
distroId = "lixos";
distroName = "LixOS";
};
2024-05-07 15:14:12 +02:00
2024-05-11 22:55:59 +02:00
environment.sessionVariables =
let
inherit (config.system.nixos) distroName version codeName;
in
{
distro = "${distroName} ${version} (${codeName}) ${system}";
};
2024-05-07 15:14:12 +02:00
documentation.doc.enable = false;
2024-05-09 20:36:33 +02:00
nix.settings.extra-sandbox-paths = [ config.programs.ccache.cacheDir ];
programs.ccache.enable = true;
2024-05-09 10:43:41 +02:00
environment.systemPackages =
2024-05-11 22:55:59 +02:00
let
inherit (lib)
getExe
attrNames
optionalString
elem
concatLines
;
inherit (pkgs) writeShellScriptBin nix-output-monitor;
in
2024-05-09 10:43:41 +02:00
[
(writeShellScriptBin "nixos-build-all" (
concatLines (
map (
n:
2024-05-09 23:00:27 +02:00
"NIXOS_TARGET_HOST=${n} nixos-rebuild build --show-trace --upgrade"
2024-05-11 22:55:59 +02:00
+ optionalString (elem nix-output-monitor config.environment.systemPackages) " |& ${getExe nix-output-monitor}"
2024-05-09 10:43:41 +02:00
) (attrNames host_modules)
)
))
];
2024-05-09 21:56:59 +02:00
nixpkgs =
2024-05-07 13:41:59 +02:00
let
src = nivSources.nixpkgs;
2024-05-09 21:56:59 +02:00
unpatched = import src { inherit config system; };
inherit (unpatched) applyPatches fetchpatch;
2024-05-07 23:31:41 +02:00
config = {
allowUnfree = true;
};
2024-05-07 13:41:59 +02:00
in
2024-05-09 21:56:59 +02:00
{
hostPlatform = system;
pkgs = import (applyPatches {
name = "nixpkgs-patched";
inherit src;
patches = map fetchpatch nixpkgs_patches;
}) { inherit config; };
overlays = [
(import (
if enable_lix_ccache then
"${
applyPatches {
name = "lix-overlay-ccache";
src = nivSources.lix-module;
patches = [ ./patches/lix-ccache.patch ];
}
}/overlay.nix"
else
"${nivSources.lix-module}/overlay.nix"
) { lix = nivSources.lix-pkg; })
(final: prev: { agenix = final.callPackage "${nivSources.agenix}/pkgs/agenix.nix" { }; })
];
};
2024-05-07 12:19:14 +02:00
2024-05-07 23:31:41 +02:00
_module.args = {
system = "x86_64-linux";
2024-05-07 20:47:08 +02:00
};
2024-05-07 12:19:14 +02:00
nix.settings.extra-substituters = [
"https://cache.lix.systems"
"https://nyx.chaotic.cx/"
];
nix.settings.trusted-public-keys = [
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
"nyx.chaotic.cx-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
"chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
];
}