Flake : Use dirs to define hosts.
This commit is contained in:
parent
5885d9e349
commit
66ed421df1
5
Makefile
5
Makefile
|
@ -16,7 +16,7 @@ boot-no-nixconf:
|
||||||
mv /etc/nix/nix.conf_ /etc/nix/nix.conf
|
mv /etc/nix/nix.conf_ /etc/nix/nix.conf
|
||||||
|
|
||||||
check:
|
check:
|
||||||
nix flake check
|
nix flake check --show-trace
|
||||||
|
|
||||||
# HACK: https://github.com/nix-community/home-manager/issues/5589
|
# HACK: https://github.com/nix-community/home-manager/issues/5589
|
||||||
fix-hm-root:
|
fix-hm-root:
|
||||||
|
@ -45,9 +45,6 @@ show:
|
||||||
switch:
|
switch:
|
||||||
nixos-rebuild switch $(options) --flake $(flake)
|
nixos-rebuild switch $(options) --flake $(flake)
|
||||||
|
|
||||||
trace:
|
|
||||||
nix flake check --show-trace
|
|
||||||
|
|
||||||
update:
|
update:
|
||||||
nix flake update
|
nix flake update
|
||||||
|
|
||||||
|
|
58
flake.nix
58
flake.nix
|
@ -142,7 +142,7 @@
|
||||||
__findFile = _: p: ./${p};
|
__findFile = _: p: ./${p};
|
||||||
|
|
||||||
# List all files in a dir.
|
# List all files in a dir.
|
||||||
lsFiles = path: map (f: "${path}/${f}") (
|
findFiles = path: map (f: "${path}/${f}") (
|
||||||
builtins.filter (i: builtins.readFileType "${path}/${i}" == "regular") (
|
builtins.filter (i: builtins.readFileType "${path}/${i}" == "regular") (
|
||||||
builtins.attrNames (builtins.readDir path)
|
builtins.attrNames (builtins.readDir path)
|
||||||
)
|
)
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
# List of modules to use by defualt for all the hosts.
|
# List of modules to use by defualt for all the hosts.
|
||||||
modules = modules ++ [
|
modules = modules ++ [
|
||||||
# There I put host-specific configurations.
|
# There I put host-specific configurations.
|
||||||
./host/${hostname}
|
./host/${system}/${hostname}
|
||||||
|
|
||||||
# Make a device hostname match the one from this config.
|
# Make a device hostname match the one from this config.
|
||||||
{ networking.hostName = hostname; }
|
{ networking.hostName = hostname; }
|
||||||
|
@ -168,10 +168,10 @@
|
||||||
|
|
||||||
# Add modules.
|
# Add modules.
|
||||||
{ imports =
|
{ imports =
|
||||||
(self.lsFiles ./config) ++
|
(self.findFiles ./config) ++
|
||||||
(self.lsFiles ./container) ++
|
(self.findFiles ./container) ++
|
||||||
(self.lsFiles ./module) ++
|
(self.findFiles ./module) ++
|
||||||
(self.lsFiles ./overlay) ++
|
(self.findFiles ./overlay) ++
|
||||||
[ ./home/NixOs.nix ];
|
[ ./home/NixOs.nix ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,39 +210,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
liveModules = [
|
|
||||||
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
|
|
||||||
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
|
|
||||||
|
|
||||||
{ networking.wireless.enable = nixpkgs.lib.mkForce false; }
|
|
||||||
|
|
||||||
# Override my settings to allow SSH logins using root password.
|
|
||||||
{ services.openssh.settings.PasswordAuthentication = nixpkgs.lib.mkForce true; }
|
|
||||||
{ services.openssh.settings.PermitRootLogin = nixpkgs.lib.mkForce "yes"; }
|
|
||||||
|
|
||||||
# Disable auto-updates as they are not possible for Live ISO.
|
|
||||||
{ module.autoupdate.enable = false; }
|
|
||||||
|
|
||||||
# Base Live images also require the LTS kernel.
|
|
||||||
{ module.kernel.latest = false; }
|
|
||||||
];
|
|
||||||
|
|
||||||
x86System = hostname: mkSystem hostname "x86_64-linux" [];
|
x86System = hostname: mkSystem hostname "x86_64-linux" [];
|
||||||
|
in nixpkgs.lib.foldl' (acc: h: acc // h) {} (
|
||||||
x86LiveSystem = hostname: mkSystem hostname "x86_64-linux" liveModules;
|
map (host: x86System host) (builtins.attrNames (builtins.readDir ./host/x86_64-linux))
|
||||||
in nixpkgs.lib.foldl' (acc: h: acc // h) {} [
|
);
|
||||||
# Bellow is the list of all the hosts I currently use.
|
|
||||||
# They call the `mkSystem` function that I defined above
|
|
||||||
# with their specific parameters.
|
|
||||||
# You might be interested in `live` and `nixOnDroidConfiguration`
|
|
||||||
# for Live ISO and Android configurations respectively.
|
|
||||||
(x86System "dasha")
|
|
||||||
(x86System "desktop")
|
|
||||||
(x86System "home")
|
|
||||||
(x86System "laptop")
|
|
||||||
(x86System "work")
|
|
||||||
(x86LiveSystem "live")
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
# Home manager (distro-independent).
|
# Home manager (distro-independent).
|
||||||
|
@ -270,7 +241,7 @@
|
||||||
inherit self inputs secret util pkgs pkgsStable pkgsMaster;
|
inherit self inputs secret util pkgs pkgsStable pkgsMaster;
|
||||||
inherit (self) const __findFile;
|
inherit (self) const __findFile;
|
||||||
};
|
};
|
||||||
modules = modules ++ (self.lsFiles ./config) ++ [
|
modules = modules ++ (self.findFiles ./config) ++ [
|
||||||
./home/HomeManager.nix
|
./home/HomeManager.nix
|
||||||
{ home.hm.enable = true; }
|
{ home.hm.enable = true; }
|
||||||
{ home.hm.username = username; }
|
{ home.hm.username = username; }
|
||||||
|
@ -292,13 +263,8 @@
|
||||||
in nixpkgs.lib.foldl' (acc: h: acc // h) {} [
|
in nixpkgs.lib.foldl' (acc: h: acc // h) {} [
|
||||||
x86LinuxRoot
|
x86LinuxRoot
|
||||||
(x86LinuxHome "voronind" [
|
(x86LinuxHome "voronind" [
|
||||||
{
|
{ home.hm.package.core.enable = true; }
|
||||||
home.hm.package = {
|
{ home.hm.package.common.enable = true; }
|
||||||
android.enable = true;
|
|
||||||
core.enable = true;
|
|
||||||
common.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{ ... }: {
|
|
||||||
home.nixos.enable = true;
|
|
||||||
}
|
|
21
host/x86_64-linux/live/default.nix
Normal file
21
host/x86_64-linux/live/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{ inputs, lib, ... }: {
|
||||||
|
imports = [
|
||||||
|
"${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
|
||||||
|
"${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
|
||||||
|
|
||||||
|
{ networking.wireless.enable = lib.mkForce false; }
|
||||||
|
|
||||||
|
# Override my settings to allow SSH logins using root password.
|
||||||
|
{ services.openssh.settings.PasswordAuthentication = lib.mkForce true; }
|
||||||
|
{ services.openssh.settings.PermitRootLogin = lib.mkForce "yes"; }
|
||||||
|
|
||||||
|
# Disable auto-updates as they are not possible for Live ISO.
|
||||||
|
{ module.autoupdate.enable = false; }
|
||||||
|
|
||||||
|
# Base Live images also require the LTS kernel.
|
||||||
|
{ module.kernel.latest = false; }
|
||||||
|
|
||||||
|
# Root user setup.
|
||||||
|
{ home.nixos.enable = true; }
|
||||||
|
];
|
||||||
|
}
|
Loading…
Reference in a new issue