diff --git a/.github/workflows/nix-package.yml b/.github/workflows/nix-package.yml index 179ff06..2e8307a 100644 --- a/.github/workflows/nix-package.yml +++ b/.github/workflows/nix-package.yml @@ -11,17 +11,10 @@ on: jobs: package-build: runs-on: ubuntu-latest - strategy: - matrix: - channel: - - nixos-23.05 - - nixos-unstable env: NIXPKGS_ALLOW_UNFREE: 1 steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v23 - with: - nix_path: nixpkgs=channel:${{ matrix.channel }} + - uses: DeterminateSystems/nix-installer-action@v6 - uses: DeterminateSystems/magic-nix-cache-action@v2 - - run: nix-shell .github/shadow-packages.nix + - run: nix flake check diff --git a/.github/workflows/update-upstream-info.yml b/.github/workflows/update-upstream-info.yml index 09d876a..f3b7b75 100644 --- a/.github/workflows/update-upstream-info.yml +++ b/.github/workflows/update-upstream-info.yml @@ -11,14 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - - name: Install Nix - uses: cachix/install-nix-action@v23 - with: - nix_path: nixpkgs=channel:nixos-23.05 - + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v6 - uses: DeterminateSystems/magic-nix-cache-action@v2 - name: Configure Git author and create branch diff --git a/checks/hmTests/default.nix b/checks/hmTests/default.nix new file mode 100644 index 0000000..664a2b0 --- /dev/null +++ b/checks/hmTests/default.nix @@ -0,0 +1,3 @@ +{ + shadow-client = ./shadow-client.nix; +} diff --git a/checks/hmTests/shadow-client.nix b/checks/hmTests/shadow-client.nix new file mode 100644 index 0000000..0a96990 --- /dev/null +++ b/checks/hmTests/shadow-client.nix @@ -0,0 +1,28 @@ +{ ... }: + +{ + programs = { + awscli = { + enable = true; + settings = { + default = { + output = "json"; + region = "eu-west-3"; + }; + }; + credentials = { iam = { credential_process = "pass show aws"; }; }; + }; + }; + + test.stubs.awscli2 = { }; + + nmt.script = '' + assertFileExists home-files/.aws/config + assertFileContent home-files/.aws/config \ + ${./aws-config.conf} + + assertFileExists home-files/.aws/credentials + assertFileContent home-files/.aws/credentials \ + ${./aws-credentials.conf} + ''; +} diff --git a/checks/nixosTests/auto.nix b/checks/nixosTests/auto.nix new file mode 100644 index 0000000..ac56bed --- /dev/null +++ b/checks/nixosTests/auto.nix @@ -0,0 +1,55 @@ +{ config, lib, ... }: + +let + dmcfg = config.services.xserver.displayManager; + cfg = config.test-support.displayManager.auto; +in +{ + + ###### interface + + options = { + test-support.displayManager.auto = { + enable = lib.mkOption { + default = false; + description = lib.mdDoc '' + Whether to enable the fake "auto" display manager, which + automatically logs in the user specified in the + {option}`user` option. This is mostly useful for + automated tests. + ''; + }; + + user = lib.mkOption { + default = "root"; + description = lib.mdDoc "The user account to login automatically."; + }; + }; + }; + + ###### implementation + + config = lib.mkIf cfg.enable { + services.xserver.displayManager = { + lightdm.enable = true; + autoLogin = { + enable = true; + user = cfg.user; + }; + }; + + # lightdm by default doesn't allow auto login for root, which is + # required by some nixos tests. Override it here. + security.pam.services.lightdm-autologin.text = lib.mkForce '' + auth requisite pam_nologin.so + auth required pam_succeed_if.so quiet + auth required pam_permit.so + + account include lightdm + + password include lightdm + + session include lightdm + ''; + }; +} diff --git a/checks/nixosTests/shadow-client.nix b/checks/nixosTests/shadow-client.nix index 76d7f07..d118299 100644 --- a/checks/nixosTests/shadow-client.nix +++ b/checks/nixosTests/shadow-client.nix @@ -5,51 +5,44 @@ pkgs.testers.runNixOSTest ({ lib, ... }: { nodes.machine = { pkgs, ... }: { imports = [ + ./x11.nix ../../modules/nixos/shadow-nix ]; - services.acme-dns = { - enable = true; - settings = { - general = rec { - domain = "acme-dns.home.arpa"; - nsname = domain; - nsadmin = "admin.home.arpa"; - records = [ - "${domain}. A 127.0.0.1" - "${domain}. AAAA ::1" - "${domain}. NS ${domain}." - ]; - }; - logconfig.loglevel = "debug"; - }; - }; - environment.systemPackages = with pkgs; [ curl bind ]; - }; - testScript = '' - import json - - machine.wait_for_unit("acme-dns.service") - machine.wait_for_open_port(53) # dns - machine.wait_for_open_port(8080) # http api + # Provides the `vainfo` command + environment.systemPackages = with pkgs; [ libva-utils ]; - result = machine.succeed("curl --fail -X POST http://localhost:8080/register") - print(result) + # Hardware hybrid decoding + # nixpkgs.config.packageOverrides = pkgs: { + # vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; + # }; - registration = json.loads(result) + # Hardware drivers + hardware.opengl = { + enable = true; + extraPackages = with pkgs; [ + vaapiIntel + vaapiVdpau + libvdpau-va-gl + intel-media-driver + ]; + }; - machine.succeed(f'dig -t TXT @localhost {registration["fulldomain"]} | grep "SOA" | grep "admin.home.arpa"') + programs.shadow-client = { + enable = true; + channel = "prod"; + }; + }; - # acme-dns exspects a TXT value string length of exactly 43 chars - txt = "___dummy_validation_token_for_txt_record___" + # enableOCR = true; - machine.succeed( - "curl --fail -X POST http://localhost:8080/update " - + f' -H "X-Api-User: {registration["username"]}"' - + f' -H "X-Api-Key: {registration["password"]}"' - + f' -d \'{{"subdomain":"{registration["subdomain"]}", "txt":"{txt}"}}\''' - ) + testScript = '' + machine.wait_for_x() - assert txt in machine.succeed(f'dig -t TXT +short @localhost {registration["fulldomain"]}') + machine.execute("shadow-prod >&2 &") + # machine.wait_for_window("Shadow PC") + # machine.wait_for_text(r"(New Game|Start Server|Load Game|Help Manual|Join Game|About|Play Online)") + machine.sleep(10) + machine.screenshot("screen") ''; }) diff --git a/checks/nixosTests/x11.nix b/checks/nixosTests/x11.nix new file mode 100644 index 0000000..0d76a0e --- /dev/null +++ b/checks/nixosTests/x11.nix @@ -0,0 +1,17 @@ +{ lib, ... }: + +{ + imports = [ + ./auto.nix + ]; + + services.xserver.enable = true; + + # Automatically log in. + test-support.displayManager.auto.enable = true; + + # Use IceWM as the window manager. + # Don't use a desktop manager. + services.xserver.displayManager.defaultSession = lib.mkDefault "none+icewm"; + services.xserver.windowManager.icewm.enable = true; +} diff --git a/flake.lock b/flake.lock index 4071c66..49a067d 100644 --- a/flake.lock +++ b/flake.lock @@ -18,17 +18,35 @@ "type": "github" } }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1698479159, + "narHash": "sha256-rJHBDwW4LbADEfhkgGHjKGfL2dF44NrlyXdXeZrQahs=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "f92a54fef4eacdbe86b0a2054054dd58b0e2a2a4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1698318101, - "narHash": "sha256-gUihHt3yPD7bVqg+k/UVHgngyaJ3DMEBchbymBMvK1E=", - "owner": "nixos", + "lastModified": 1697456312, + "narHash": "sha256-roiSnrqb5r+ehnKCauPLugoU8S36KgmWraHgRqVYndo=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "63678e9f3d3afecfeafa0acead6239cdb447574c", + "rev": "ca012a02bf8327be9e488546faecae5e05d7d749", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" @@ -52,10 +70,27 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1698318101, + "narHash": "sha256-gUihHt3yPD7bVqg+k/UVHgngyaJ3DMEBchbymBMvK1E=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "63678e9f3d3afecfeafa0acead6239cdb447574c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" } } }, diff --git a/flake.nix b/flake.nix index 23528bd..6c71fc6 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; + home-manager.url = "github:nix-community/home-manager"; }; outputs = inputs@{ flake-parts, ... }: diff --git a/import/.drirc b/import/.drirc deleted file mode 100644 index 81bcde6..0000000 --- a/import/.drirc +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/modules/hm/shadow-nix/default.nix b/modules/hm/shadow-nix/default.nix index 7870c42..db53101 100644 --- a/modules/hm/shadow-nix/default.nix +++ b/modules/hm/shadow-nix/default.nix @@ -28,7 +28,7 @@ in { ] ++ lib.forEach cfg.extraChannels shadow-package; # Add GPU fixes - file.".drirc".source = lib.mkIf (cfg.enableGpuFix) ../.drirc; + file.".drirc".source = lib.mkIf (cfg.enableGpuFix) ../../.drirc; # Force VA Driver sessionVariables.LIBVA_DRIVER_NAME = toString cfg.forceDriver; diff --git a/modules/nixos/shadow-nix/default.nix b/modules/nixos/shadow-nix/default.nix index 98a22c6..72353b9 100644 --- a/modules/nixos/shadow-nix/default.nix +++ b/modules/nixos/shadow-nix/default.nix @@ -30,7 +30,7 @@ in { ] ++ lib.forEach cfg.extraChannels shadow-package; # Add GPU fixes - etc.drirc.source = lib.mkIf (cfg.enableGpuFix) ../.drirc; + etc.drirc.source = lib.mkIf (cfg.enableGpuFix) ../../.drirc; # Force VA Driver variables.LIBVA_DRIVER_NAME = lib.mkIf (cfg.forceDriver != null) [ cfg.forceDriver ];