From 6079344446d3686f369d65d62ed3eb70ee695d01 Mon Sep 17 00:00:00 2001 From: Gabriele Modena Date: Wed, 7 Feb 2024 22:41:43 +0100 Subject: [PATCH] Add testing-base. (#36) Add a base 23.11 nixos system with Gnome, GDM and nix-flatpak installed. --- testing-base/README.md | 19 ++++++++++++ testing-base/common.nix | 54 ++++++++++++++++++++++++++++++++++ testing-base/configuration.nix | 13 ++++++++ testing-base/flake.lock | 40 +++++++++++++++++++++++++ testing-base/flake.nix | 21 +++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 testing-base/README.md create mode 100644 testing-base/common.nix create mode 100644 testing-base/configuration.nix create mode 100644 testing-base/flake.lock create mode 100644 testing-base/flake.nix diff --git a/testing-base/README.md b/testing-base/README.md new file mode 100644 index 0000000..6d37c29 --- /dev/null +++ b/testing-base/README.md @@ -0,0 +1,19 @@ +# Testing base + +A base GDM + Gnome `nixos` system to experiment with `nix-flatpak`. + +Build a qemu virtual machine with +```bash +nix build .#nixosConfigurations.test-system-module.config.system.build.vm +``` + +start the system with +```bash +export QEMU_NET_OPTS="hostfwd=tcp::2221-:22" +result/bin/run-nixos-vm +``` + +and ssh into the vm with +```bash +ssh -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no antani@localhost -p 2221 +``` diff --git a/testing-base/common.nix b/testing-base/common.nix new file mode 100644 index 0000000..784af99 --- /dev/null +++ b/testing-base/common.nix @@ -0,0 +1,54 @@ +# configuration.nix +{ config, lib, pkgs, ... }: { + users.users.antani = { + isNormalUser = true; + home = "/home/antani"; + extraGroups = [ "wheel" ]; # Enables `sudo` for the user. + password = "changeme"; # The password assigned if the user does not already exist. + }; + + virtualisation.vmVariant = { + # following configuration is added only when building VM with build-vm + virtualisation = { + memorySize = 1024; # Use 1024MiB memory. + cores = 2; + graphics = true; # Boot the vm in a window. + diskSize = 1000; # Virtual machine disk size in MB. + }; + }; + + services.openssh = { + enable = true; + settings.PasswordAuthentication = true; + }; + + networking.firewall.allowedTCPPorts = [ 22 ]; + environment.systemPackages = with pkgs; [ + git + vim + ]; + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + # Required to install flatpak + xdg.portal = { + enable = true; + config = { + common = { + default = [ + "gtk" + ]; + }; + }; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + # xdg-desktop-portal-kde + # xdg-desktop-portal-gtk + ]; + }; + + system.stateVersion = "23.11"; +} diff --git a/testing-base/configuration.nix b/testing-base/configuration.nix new file mode 100644 index 0000000..8bc0553 --- /dev/null +++ b/testing-base/configuration.nix @@ -0,0 +1,13 @@ +# configuration.nix +{ config, lib, pkgs, ... }: { + imports = [ + ./common.nix + ]; + # nix-flatpak setup + services.flatpak.enable = true; + services.flatpak.update.auto.enable = false; + services.flatpak.uninstallUnmanagedPackages = true; + services.flatpak.packages = [ + # ... + ]; +} diff --git a/testing-base/flake.lock b/testing-base/flake.lock new file mode 100644 index 0000000..1b65f8a --- /dev/null +++ b/testing-base/flake.lock @@ -0,0 +1,40 @@ +{ + "nodes": { + "flatpaks": { + "locked": { + "lastModified": 0, + "narHash": "sha256-SawYARayiNIHSzlJ+53b6VF3znhaaMa0sTpJ9vupF+I=", + "path": "/nix/store/02k7ls0yqyl1gx6v4298c9vp1phh04as-source", + "type": "path" + }, + "original": { + "path": "/nix/store/02k7ls0yqyl1gx6v4298c9vp1phh04as-source", + "type": "path" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1707091808, + "narHash": "sha256-LahKBAfGbY836gtpVNnWwBTIzN7yf/uYM/S0g393r0Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9f2ee8c91ac42da3ae6c6a1d21555f283458247e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flatpaks": "flatpaks", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/testing-base/flake.nix b/testing-base/flake.nix new file mode 100644 index 0000000..acca659 --- /dev/null +++ b/testing-base/flake.nix @@ -0,0 +1,21 @@ +# flake.nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flatpaks.url = "../"; + }; + outputs = inputs@{ self, nixpkgs, flatpaks, ... }: + let + system = "x86_64-linux"; + in + { + # hostname = test-system-module + nixosConfigurations.test-system-module = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + flatpaks.nixosModules.nix-flatpak + ./configuration.nix + ]; + }; + }; +}