From 9b6a5d9199450af8c6a705c63f9f537f71d3eeac Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Sat, 16 Nov 2024 17:15:56 +0100 Subject: [PATCH] feat: add devel image --- flake.nix | 24 +++++++++++++++++++ justfile | 8 +++++++ modules/profiles/base.nix | 6 ++--- modules/profiles/devel.nix | 48 +++++++++++++++++++++++++++++++++++++ modules/profiles/server.nix | 31 +++--------------------- tests/common.nix | 2 +- 6 files changed, 87 insertions(+), 32 deletions(-) create mode 100644 modules/profiles/devel.nix diff --git a/flake.nix b/flake.nix index d45c794..0e245dd 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,10 @@ pkgs = import nixpkgs { inherit system; }; in { + nixosModules.devel.imports = [ + ./modules/profiles/devel.nix + ]; + nixosModules.server.imports = [ ./modules/profiles/server.nix ]; @@ -25,6 +29,26 @@ ]; packages.${system} = { + devel = + (nixpkgs.lib.nixosSystem { + modules = [ + ( + { lib, ... }: + { + nixpkgs.hostPlatform = system; + system.stateVersion = "24.05"; + } + ) + { + system.image.updates.url = "${updateUrl}"; + system.image.id = "patos"; + system.image.version = releaseVersion; + } + self.nixosModules.image + self.nixosModules.devel + ]; + }).config.system.build.updatePackage; + patos = (nixpkgs.lib.nixosSystem { modules = [ diff --git a/justfile b/justfile index dfb84a2..fe3a2d8 100644 --- a/justfile +++ b/justfile @@ -15,5 +15,13 @@ build: build-image build-image: nix build .#patos +# Build PatOS image (developer mode) +build-devel-image: + nix build .#devel + run: build-image qemu-uefi-tpm ./result/*.img + +run-devel: build-devel-image + qemu-uefi-tpm ./result/*.img + diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 358d8a8..efb9b9a 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -79,9 +79,9 @@ "nomodeset" "console=tty1" "console=ttyS0,38400" - "systemd.log_level=info" - "systemd.log_target=console" - "systemd.journald.forward_to_console" + # "systemd.log_level=info" + # "systemd.log_target=console" + # "systemd.journald.forward_to_console" ]; # This is vi country diff --git a/modules/profiles/devel.nix b/modules/profiles/devel.nix new file mode 100644 index 0000000..323bfce --- /dev/null +++ b/modules/profiles/devel.nix @@ -0,0 +1,48 @@ +{ + modulesPath, + ... +}: +{ + + imports = [ ./server.nix ]; + + boot.kernel.sysctl = { + "net.ipv4.ip_unprivileged_port_start" = 0; + }; + + boot.kernelParams = [ + "systemd.log_level=info" + "systemd.log_target=console" + "systemd.journald.forward_to_console" + ]; + + users.users."admin" = { + isNormalUser = true; + linger = true; + extraGroups = [ "wheel" ]; + }; + + environment.etc = { + subuid = { + text = "admin:100000:65536"; + mode = "0644"; + }; + + subgid = { + text = "admin:100000:65536"; + mode = "0644"; + }; + }; + + services.getty.autologinUser = "admin"; + + services.openssh.enable = true; + system.image.sshKeys.enable = true; + system.image.sshKeys.keys = [ + "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIIHMAEZx02kbHrEygyPQYStiXlrIe6EIqBCv7anIkL0pAAAABHNzaDo= dln1" + "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIJNOBFoU7Cdsgi4KpYRcv7EhR/8kD4DYjEZnwk6urRx7AAAABHNzaDo= dln2" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKDx+7ZEJi7lUCAtoHRRIduJzH3hrpx4YS1f0ZxrJ+uW dln3" + "sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBLpoKvsZDIQQLfgzJhe1jAQubBNxjydkj8UfdUPaSXqgfB02OypMOC1m5ZuJYcQIxox0I+4Z8xstFhYP6s8zKZwAAAAEc3NoOg== lsjostro1" + "sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBJ10mLOpInoqDaySyrxbzvcOrJfLw48Y6eWHa9501lw+hEEBXya3ib7nlvpCqEQJ8aPU5fVRqpkOW5zSimCiRbwAAAAEc3NoOg== lsjostro2" + ]; +} diff --git a/modules/profiles/server.nix b/modules/profiles/server.nix index c7890b8..b17f264 100644 --- a/modules/profiles/server.nix +++ b/modules/profiles/server.nix @@ -10,35 +10,10 @@ ./sysext.nix ]; - boot.kernel.sysctl = { - "net.ipv4.ip_unprivileged_port_start" = 0; - }; - - users.users."admin" = { - isNormalUser = true; - linger = true; - extraGroups = [ "wheel" ]; - }; - - environment.etc = { - subuid = { - text = "admin:100000:65536"; - mode = "0644"; - }; - - subgid = { - text = "admin:100000:65536"; - mode = "0644"; - }; - }; - - services.openssh.enable = true; - system.image.sshKeys.enable = true; - system.image.sshKeys.keys = [ - "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIIHMAEZx02kbHrEygyPQYStiXlrIe6EIqBCv7anIkL0pAAAABHNzaDo= dln1" - "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIJNOBFoU7Cdsgi4KpYRcv7EhR/8kD4DYjEZnwk6urRx7AAAABHNzaDo= dln2" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKDx+7ZEJi7lUCAtoHRRIduJzH3hrpx4YS1f0ZxrJ+uW dln3" + boot.kernelParams = [ + "quiet" ]; + virtualisation.podman.enable = true; } diff --git a/tests/common.nix b/tests/common.nix index 23232be..88bf95c 100644 --- a/tests/common.nix +++ b/tests/common.nix @@ -42,7 +42,7 @@ rec { boot.initrd.compressorArgs = lib.mkForce [ "-8" ]; } (pkgs.path + "/nixos/modules/testing/test-instrumentation.nix") - self.nixosModules.server + self.nixosModules.devel self.nixosModules.image extraConfig ];