From 482566b84fc9b30538ae4dd090e77a0979aa1a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 17 Jul 2022 19:35:04 +0200 Subject: nixos: allow tarball build and cross-build directly --- nixos/modules/turris-crossbuild.nix | 21 ++++++++++ nixos/modules/turris-defaults.nix | 2 +- nixos/modules/turris-tarball.nix | 78 +++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 nixos/modules/turris-crossbuild.nix create mode 100644 nixos/modules/turris-tarball.nix (limited to 'nixos/modules') 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 <