MG
Size: a a a
MG
АБ
unstable: final: prev: {
linux = prev.linux.overrideAttrs (_: {
patches = [ ./linux.patch ];
});
inherit (unstable) lib1 lib2 foobar;
}
АБ
configuration.nix
описание машиныMG
АБ
MG
АБ
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-20.03";
nixpkgs-unstable.url = "github:nixos/nixpkgs-channels/nixos-unstable";
};
outputs = { self, nixpkgs, nixpkgs-unstable }: {
nixosConfigurations = let
mkMachine = hostName:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{ networking.hostName = hostName; }
{ nixpkgs.overlays = [ (import ./overlay.nix nixpkgs-unstable) ]; }
./configuration.nix
];
};
in builtins.listToAttrs (map (name: {
inherit name;
value = mkMachine name;
}) [ "machine1" "machine2" "machine3" ]);
};
}
АБ
configuration.nix
делаешь например services.nginx.enable = config.networking.hostName == "machine2";
В
АБ
АБ
configuration.nix
делаешь например services.nginx.enable = config.networking.hostName == "machine2";
АБ
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-20.03";
nixpkgs-unstable.url = "github:nixos/nixpkgs-channels/nixos-unstable";
};
outputs = { self, nixpkgs, nixpkgs-unstable }: {
nixosConfigurations = let
mkMachine = hostName:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{ networking.hostName = hostName; }
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
{ nixpkgs.overlays = [ (import ./overlay.nix nixpkgs-unstable) ]; }
./configuration.nix
];
};
in builtins.listToAttrs (map (name: {
inherit name;
value = mkMachine name;
}) [ "machine1" "machine2" "machine3" ]);
};
}
АБ
MG
АБ
АБ
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-20.03";
nixpkgs-unstable.url = "github:nixos/nixpkgs-channels/nixos-unstable";
};
outputs = { self, nixpkgs, nixpkgs-unstable }: {
nixosConfigurations = let
installScript = hostName:
nixpkgs.legacyPackages.x86_64-linux.writeShellScriptBin "installer" ''
${
(nixpkgs.legacyPackages.x86_64-linux.nixos { }).nixos-install
}/bin/nixos-install --system ${mkMachine hostName}
'';
mkMachine = hostName:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{ networking.hostName = hostName; }
{ nixpkgs.overlays = [ (import ./overlay.nix nixpkgs-unstable) ]; }
./configuration.nix
];
};
mkInstaller = hostName:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
{ environment.systemPackages = [ (installScript hostName) ]; }
];
};
in builtins.listToAttrs (builtins.concatMap (name: [
{
inherit name;
value = mkMachine name;
}
{
name = "${name}-installer";
value = mkInstaller name;
}
]) [ "machine1" "machine2" "machine3" ]);
};
}
АБ
АБ
nix build .#nixosConfigurations.machine1-installer.config.system.build.isoImage
, грузишь с флешки, размечаешь диск, installer
, смотришь на процесс установки