diff options
-rw-r--r-- | flake.lock | 12 | ||||
-rw-r--r-- | flake.nix | 12 | ||||
-rw-r--r-- | lib/default.nix | 13 | ||||
-rw-r--r-- | nixos/default.nix | 2 | ||||
-rw-r--r-- | nixos/modules/turris-crossbuild.nix | 21 | ||||
-rw-r--r-- | nixos/modules/turris-defaults.nix | 2 | ||||
-rw-r--r-- | nixos/modules/turris-tarball.nix | 78 | ||||
-rw-r--r-- | tarball.nix | 57 |
8 files changed, 116 insertions, 81 deletions
@@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1656065134, - "narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=", + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", "owner": "numtide", "repo": "flake-utils", - "rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", "type": "github" }, "original": { @@ -16,11 +16,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1656633783, - "narHash": "sha256-nXMIGtQXBGzO57nkPxgEOx8HLRwVQ+d1WkOnE01JG4A=", + "lastModified": 1657975505, + "narHash": "sha256-juMbw+GY2ycTrg3QbdFfEQs6P3FJeoYEv8aMVl2EZsg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "95e79164be1f7d883ed9ffda8b7d4ad3a17e6c1e", + "rev": "d6df226c53d46821bd4773bd7ec3375f30238edb", "type": "github" }, "original": { @@ -15,8 +15,8 @@ lib = import ./lib { inherit self; nixpkgsDefault = nixpkgs; }; nixosConfigurations = { - tarballMox = self.lib.nixturrisTarballSystem { board = "mox"; nixpkgs = nixpkgs; }; - tarballOmnia = self.lib.nixturrisTarballSystem { board = "omnia"; nixpkgs = nixpkgs; }; + mox = self.lib.nixturrisSystem { board = "mox"; nixpkgs = nixpkgs; }; + omnia = self.lib.nixturrisSystem { board = "omnia"; nixpkgs = nixpkgs; }; }; } // eachSystem supportedHostSystems ( @@ -26,11 +26,11 @@ tarball = nixos: nixos.config.system.build.tarball; in { - tarballMox = tarball self.nixosConfigurations.tarballMox; - tarballOmnia = tarball self.nixosConfigurations.tarballOmnia; + tarballMox = tarball self.nixosConfigurations.mox; + tarballOmnia = tarball self.nixosConfigurations.omnia; - crossTarballMox = tarball (self.lib.nixturrisTarballSystem { board = "mox"; nixpkgs = nixpkgs; system = system; }); - crossTarballOmnia = tarball (self.lib.nixturrisTarballSystem { board = "omnia"; nixpkgs = nixpkgs; system = system; }); + crossTarballMox = tarball self.nixosConfigurations.mox.config.system.build.cross.${system}; + crossTarballOmnia = tarball self.nixosConfigurations.omnia.config.system.build.cross.${system}; } // filterPackages system (flattenTree ( import ./pkgs { nixpkgs = nixpkgs.legacyPackages."${system}"; } diff --git a/lib/default.nix b/lib/default.nix index 211451e..1136741 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -16,18 +16,13 @@ nixturrisSystem = { board, nixpkgs ? nixpkgsDefault, - system ? boardSystem.${board}.system, modules ? [], override ? {} }: nixpkgs.lib.nixosSystem ({ - system = system; + system = boardSystem.${board}.system; modules = [ self.nixosModules.default - ({ - turris.board = board; - } // nixpkgs.lib.optionalAttrs (system != boardSystem.${board}.system) { - nixpkgs.crossSystem = boardSystem.${board}; - }) + { turris.board = board; } ] ++ modules; } // override); @@ -45,8 +40,4 @@ }; }); - nixturrisTarballSystem = {...} @args: (nixturrisSystem ({ - modules = [ (import ../tarball.nix args.board) ]; - } // args)); - } diff --git a/nixos/default.nix b/nixos/default.nix index 79ce6e1..7274f66 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -4,6 +4,8 @@ self: let turris-board = import ./modules/turris-board.nix; turris-defaults = import ./modules/turris-defaults.nix; + turris-tarball = import ./modules/turris-tarball.nix; + turris-crossbuild = import ./modules/turris-crossbuild.nix; hostapd = import ./modules/hostapd.nix; diff --git a/nixos/modules/turris-crossbuild.nix b/nixos/modules/turris-crossbuild.nix new file mode 100644 index 0000000..1f107bd --- /dev/null +++ b/nixos/modules/turris-crossbuild.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, modulesPath, extendModules, ... }: + +with lib; + +let + + crossVariant = host: extendModules { + modules = [{ + nixpkgs.system = host; + nixpkgs.crossSystem = { + inherit (config.nixpkgs.localSystem) system config; + }; + }]; + }; + +in mkIf (config.nixpkgs.crossSystem == null) { + + # TODO for each common platform + system.build.cross.x86_64-linux = crossVariant "x86_64-linux"; + +} diff --git a/nixos/modules/turris-defaults.nix b/nixos/modules/turris-defaults.nix index 5de0d44..ee7f88e 100644 --- a/nixos/modules/turris-defaults.nix +++ b/nixos/modules/turris-defaults.nix @@ -83,7 +83,7 @@ in { ] ++ optionals (config.turris.board == "mox") [ #mox-otp ] ++ optionals (config.turris.board == "omnia") [ - #libatsha204 + libatsha204 ]; # No need for installer tools in standard system diff --git a/nixos/modules/turris-tarball.nix b/nixos/modules/turris-tarball.nix new file mode 100644 index 0000000..5a1f672 --- /dev/null +++ b/nixos/modules/turris-tarball.nix @@ -0,0 +1,78 @@ +{ config, lib, pkgs, modulesPath, extendModules, ... }: + +with lib; + +let + + tarballVariant = extendModules { + modules = [{ + boot.consoleLogLevel = lib.mkDefault 7; + + # Allow access to the root account right after installation + users = { + mutableUsers = false; + users.root.password = mkDefault "nixturris"; + }; + + # Allow root access over SSH + services.openssh = { + enable = true; + passwordAuthentication = true; + permitRootLogin = "yes"; + }; + + # TODO we have to generate the hardware specific configuration on first boot + boot.postBootCommands = '' + ''; + + environment.etc."nixos/flake.nix" = { + mode = "0600"; + text = '' + { + inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-21.11"; + inputs.nixturris.url = "git+https://git.cynerd.cz/nixturris"; + outputs = { self, nixpkgs-stable, nixturris }: { + nixosConfigurations.nixturris = nixturris.lib.nixturrisSystem { + nixpkgs = nixpkgs-stable; + board = "${config.turris.board}"; + modules = [({ config, lib, pkgs, ... }: { + # Optionally place your configuration here + })]; + }; + }; + } + ''; + }; + system.extraSystemBuilderCmds = '' + mkdir -p $out/boot/extlinux + cat >$out/boot/extlinux/extlinux.conf <<EOF + DEFAULT nixos-default + TIMEOUT 0 + LABEL nixos-default + MENU LABEL NixOS - Default + LINUX /run/current-system/kernel + FDTDIR /run/current-system/dtbs + INITRD /run/current-system/initrd + APPEND init=${config.system.build.toplevel}/init ${builtins.toString config.boot.kernelParams} + EOF + ''; + }]; + }; + +in { + + system.build.tarball = pkgs.callPackage "${modulesPath}/../lib/make-system-tarball.nix" { + contents = [ + { + source = "${tarballVariant.config.system.build.toplevel}/."; + target = "./"; + } + ]; + + storeContents = map (x: { object = x; symlink = "none"; }) [ + tarballVariant.config.system.build.toplevel + pkgs.stdenv + ]; + }; + +} diff --git a/tarball.nix b/tarball.nix deleted file mode 100644 index 9327762..0000000 --- a/tarball.nix +++ /dev/null @@ -1,57 +0,0 @@ -board: { config, lib, pkgs, modulesPath, ... }: - -with lib; - -{ - imports = [ - "${toString modulesPath}/installer/cd-dvd/system-tarball.nix" - ]; - - boot.consoleLogLevel = lib.mkDefault 7; - - # Allow access to the root account right after installation - users = { - mutableUsers = false; - users.root.password = mkDefault "nixturris"; - }; - - # Allow root access over SSH - services.openssh = { - enable = true; - passwordAuthentication = true; - permitRootLogin = "yes"; - }; - - # TODO we have to generate the hardware specific configuration on first boot - tarball.contents = [ - { source = pkgs.writeText "default-nixturris-flake" '' - { - inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-21.11"; - inputs.nixturris.url = "git+https://git.cynerd.cz/nixturris"; - outputs = { self, nixpkgs-stable, nixturris }: { - nixosConfigurations.nixturris = nixturris.lib.nixturrisSystem { - nixpkgs = nixpkgs-stable; - board = "${board}"; - modules = [({ config, lib, pkgs, ... }: { - # Optionally place your configuration here - })]; - }; - }; - } - ''; - target = "/etc/nixos/flake.nix"; - } - { source = pkgs.writeText "medkit-extlinux" '' - DEFAULT nixos-default - TIMEOUT 0 - LABEL nixos-default - MENU LABEL NixOS - Default - LINUX /run/current-system/kernel - FDTDIR /run/current-system/dtbs - INITRD /run/current-system/initrd - APPEND init=${config.system.build.toplevel}/init ${builtins.toString config.boot.kernelParams} - ''; - target = "/boot/extlinux/extlinux.conf"; - } - ]; -} |