update private config sample

This commit is contained in:
chayleaf 2023-05-25 05:09:17 +07:00
parent 10f795dbb3
commit d86b83c319
4 changed files with 132 additions and 127 deletions

226
flake.nix
View file

@ -30,125 +30,125 @@
}; };
outputs = inputs@{ self, nixpkgs, nixos-hardware, impermanence, home-manager, nur, nix-gaming, notlua, nixos-mailserver, ... }: outputs = inputs@{ self, nixpkgs, nixos-hardware, impermanence, home-manager, nur, nix-gaming, notlua, nixos-mailserver, ... }:
let let
# IRL-related stuff I'd rather not put into git # IRL-related stuff I'd rather not put into git
priv = priv =
if builtins.pathExists ./private.nix then (import ./private.nix) if builtins.pathExists ./private.nix then (import ./private.nix)
else if builtins.pathExists ./private/default.nix then (import ./private) else if builtins.pathExists ./private/default.nix then (import ./private)
else { }; else { };
getOr = def: s: x: with builtins; if hasAttr s x then getAttr s x else def; getOr = def: s: x: with builtins; if hasAttr s x then getAttr s x else def;
getPriv = hostname: getOr { } hostname priv; getPriv = hostname: getOr { } hostname priv;
getPrivSys = hostname: getOr { } "system" (getPriv hostname); getPrivSys = hostname: getOr { } "system" (getPriv hostname);
getPrivUser = hostname: user: getOr { } user (getPriv hostname); getPrivUser = hostname: user: getOr { } user (getPriv hostname);
lib = nixpkgs.lib // { lib = nixpkgs.lib // {
quoteListenAddr = addr: quoteListenAddr = addr:
if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr; if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr;
}; };
config = { config = {
nixmsi = rec { nixmsi = rec {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
nix-gaming.nixosModules.pipewireLowLatency nix-gaming.nixosModules.pipewireLowLatency
./system/hardware/msi_delta_15.nix ./system/hardware/msi_delta_15.nix
./system/hosts/nixmsi.nix ./system/hosts/nixmsi.nix
]; ];
home.user = { home.user = {
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
binaryCachePublicKeys = [ binaryCachePublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
# "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=" # "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
]; ];
binaryCaches = [ binaryCaches = [
"https://cache.nixos.org" "https://cache.nixos.org"
# "https://nixpkgs-wayland.cachix.org" # "https://nixpkgs-wayland.cachix.org"
]; ];
overlays = [ overlays = [
(self: super: import ./home/pkgs { (self: super: import ./home/pkgs {
# can't use callPackage here, idk why # can't use callPackage here, idk why
pkgs = super;
lib = super.lib;
nur = import nur {
pkgs = super; pkgs = super;
lib = super.lib; nurpkgs = super;
nur = import nur { };
pkgs = super; nix-gaming = nix-gaming.packages.${system};
nurpkgs = super; })
};
nix-gaming = nix-gaming.packages.${system};
})
];
};
extraSpecialArgs = {
notlua = notlua.lib.${system};
# pkgs-wayland = nixpkgs-wayland.packages.${system};
};
modules = [
nur.nixosModules.nur
./home/hosts/nixmsi.nix
]; ];
}; };
}; extraSpecialArgs = {
nixserver = { notlua = notlua.lib.${system};
# pkgs-wayland = nixpkgs-wayland.packages.${system};
};
modules = [ modules = [
nixos-mailserver.nixosModules.default nur.nixosModules.nur
./system/hardware/hp_probook_g0.nix ./home/hosts/nixmsi.nix
./system/hosts/nixserver
];
};
router = {
system = "aarch64-linux";
modules = [
./system/hardware/bpi_r3.nix
./system/hosts/router
]; ];
}; };
}; };
in { nixserver = {
nixosConfigurations = builtins.mapAttrs (hostname: args @ { system ? "x86_64-linux", modules, ... }: modules = [
lib.nixosSystem ({ nixos-mailserver.nixosModules.default
inherit system; ./system/hardware/hp_probook_g0.nix
modules = modules ++ [ ./system/hosts/nixserver
{ networking.hostName = hostname; } ];
./system/modules/vfio.nix };
./system/modules/ccache.nix router = {
./system/modules/impermanence.nix system = "aarch64-linux";
./system/modules/common.nix modules = [
impermanence.nixosModule ./system/hardware/bpi_r3.nix
(getPrivSys hostname) ./system/hosts/router
{ ];
nix.registry = };
builtins.mapAttrs
(_: v: { flake = v; })
(lib.filterAttrs (_: v: v?outputs) inputs);
# add import'able flakes (like nixpkgs) to nix path
environment.etc = lib.mapAttrs'
(name: value: {
name = "nix/inputs/${name}";
value = { source = value.outPath; };
})
(lib.filterAttrs (_: v: builtins.pathExists "${v}/default.nix") inputs);
nix.nixPath = [ "/etc/nix/inputs" ];
}
];
specialArgs = {
inherit lib nixpkgs;
hardware = nixos-hardware.nixosModules;
};
} // (builtins.removeAttrs args [ "home" "modules" ])))
config;
homeConfigurations =
builtins.foldl'
(a: b: a // b)
{ }
(builtins.concatLists
(lib.mapAttrsToList
(hostname: config:
lib.mapAttrsToList
(user: config@{ modules, ... }: {
"${user}@${hostname}" = home-manager.lib.homeManagerConfiguration (config // {
modules = config.modules ++ [ (getPrivUser hostname user) ];
});
})
(getOr { } "home" config))
config));
}; };
in {
nixosConfigurations = builtins.mapAttrs (hostname: args @ { system ? "x86_64-linux", modules, ... }:
lib.nixosSystem ({
inherit system;
modules = modules ++ [
{ networking.hostName = hostname; }
./system/modules/vfio.nix
./system/modules/ccache.nix
./system/modules/impermanence.nix
./system/modules/common.nix
impermanence.nixosModule
(getPrivSys hostname)
{
nix.registry =
builtins.mapAttrs
(_: v: { flake = v; })
(lib.filterAttrs (_: v: v?outputs) inputs);
# add import'able flakes (like nixpkgs) to nix path
environment.etc = lib.mapAttrs'
(name: value: {
name = "nix/inputs/${name}";
value = { source = value.outPath; };
})
(lib.filterAttrs (_: v: builtins.pathExists "${v}/default.nix") inputs);
nix.nixPath = [ "/etc/nix/inputs" ];
}
];
specialArgs = {
inherit lib nixpkgs;
hardware = nixos-hardware.nixosModules;
};
} // (builtins.removeAttrs args [ "home" "modules" ])))
config;
homeConfigurations =
builtins.foldl'
(a: b: a // b)
{ }
(builtins.concatLists
(lib.mapAttrsToList
(hostname: config:
lib.mapAttrsToList
(user: config@{ modules, ... }: {
"${user}@${hostname}" = home-manager.lib.homeManagerConfiguration (config // {
modules = config.modules ++ [ (getPrivUser hostname user) ];
});
})
(getOr { } "home" config))
config));
};
} }

View file

@ -1,5 +0,0 @@
{
nixmsi = { pkgs, ... }: {
# insert private config here
};
}

19
private.nix.sample Normal file
View file

@ -0,0 +1,19 @@
{
nixmsi = {
system = { pkgs, ... }: {
# insert private config here
time.timeZone = ...;
users.users.root.initialHashedPassword = ...;
users.users.user.initialHashedPassword = ...;
};
username = { pkgs, ... }: {
# insert private user config for username here
};
};
nixserver.system = { ... }: {
server.localIpV4 = ...;
server.lanCidrV4 = ...;
server.localIpV6 = ...;
server.lanCidrV6 = ...;
};
}

View file

@ -1,9 +0,0 @@
{
nixmsi = { pkgs, lib, ... }: {
# insert private config here
# time.timeZone = ...;
# users.users.root.initialHashedPassword = ...;
# users.users.user.initialHashedPassword = ...;
};
nixserver = { ... }: { };
}