diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08c75d9..bb18355 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,20 +10,19 @@ jobs: contents: write packages: write steps: - - uses: actions/checkout@v3 - # - uses: docker/setup-qemu-action@v2 - # with: - # platforms: arm64 - - uses: cachix/install-nix-action@v22 - # with: - # extra_nix_config: | - # extra-platforms = aarch64-linux + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + - uses: DeterminateSystems/nix-installer-action@v9 + with: + extra-conf: | + extra-platforms = aarch64-linux + - uses: DeterminateSystems/magic-nix-cache-action@v3 - uses: cihelper/action-semanticrelease-npm@v1 id: semanticrelease - - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ github.token }} - run: nix run .#dockerManifest --impure if: ${{ steps.semanticrelease.outputs.released == 'true' }} + env: + VERSION: ${{ steps.semanticrelease.outputs.version }} + GH_TOKEN: ${{ github.token }} diff --git a/flake.nix b/flake.nix index c5223ed..8ddea64 100644 --- a/flake.nix +++ b/flake.nix @@ -8,98 +8,102 @@ flake = false; }; flocken = { - url = "github:mirkolenz/flocken/v1"; + url = "github:mirkolenz/flocken/v2"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = inputs @ { - nixpkgs, - flake-parts, - systems, - flocken, - self, - ... - }: - flake-parts.lib.mkFlake {inherit inputs;} { + outputs = + inputs@{ + nixpkgs, + flake-parts, + systems, + flocken, + self, + ... + }: + flake-parts.lib.mkFlake { inherit inputs; } { systems = import systems; - perSystem = { - pkgs, - system, - lib, - self', - ... - }: let - nodejs = pkgs.nodejs_20; - npmlock2nix = import inputs.npmlock2nix {inherit pkgs;}; - caddyport = "8080"; - caddyfile = pkgs.writeText "caddyfile" '' - { - admin off - auto_https off - persist_config off - } - :${caddyport} { - root * ${self'.packages.default} - encode gzip - file_server { - index index.html + perSystem = + { + pkgs, + system, + lib, + self', + ... + }: + let + nodejs = pkgs.nodejs_20; + npmlock2nix = import inputs.npmlock2nix { inherit pkgs; }; + caddyport = "8080"; + caddyfile = pkgs.writeText "caddyfile" '' + { + admin off + auto_https off + persist_config off + } + :${caddyport} { + root * ${self'.packages.default} + encode gzip + file_server { + index index.html + } } - } - ''; - in { - devShells.default = pkgs.mkShell { - shellHook = '' - ${lib.getExe' nodejs "npm"} install - ${lib.getExe nodejs} --version > .node-version ''; - packages = [nodejs]; - }; - apps.dockerManifest = { - type = "app"; - program = lib.getExe (flocken.legacyPackages.${system}.mkDockerManifest { - branch = builtins.getEnv "GITHUB_REF_NAME"; - name = "ghcr.io/" + builtins.getEnv "GITHUB_REPOSITORY"; - version = builtins.getEnv "VERSION"; - images = with self.packages; [x86_64-linux.docker aarch64-linux.docker]; - }); - }; - packages = { - default = npmlock2nix.v2.build { - src = ./.; - installPhase = "cp -r dist/. $out"; - buildCommands = [ - "HOME=$TMPDIR" - "npm run build" - ]; - node_modules_attrs = { - inherit nodejs; - # Python is needed for node-gyp/libsass - buildInputs = with pkgs; [python3]; - }; - }; - arguemapper = self'.packages.default; - server = pkgs.writeShellApplication { - name = "server"; - text = '' - ${lib.getExe pkgs.caddy} run --config ${caddyfile} --adapter caddyfile + in + { + devShells.default = pkgs.mkShell { + shellHook = '' + ${lib.getExe' nodejs "npm"} install + ${lib.getExe nodejs} --version > .node-version ''; + packages = [ nodejs ]; }; - docker = pkgs.dockerTools.buildLayeredImage { - name = "arguemapper"; - tag = "latest"; - created = "now"; - contents = [ - pkgs.dockerTools.fakeNss - ]; - config = { - entrypoint = [(lib.getExe self'.packages.server)]; - exposedPorts = { - "${caddyport}/tcp" = {}; + packages = { + default = npmlock2nix.v2.build { + src = ./.; + installPhase = "cp -r dist/. $out"; + buildCommands = [ + "HOME=$TMPDIR" + "npm run build" + ]; + node_modules_attrs = { + inherit nodejs; + # Python is needed for node-gyp/libsass + buildInputs = with pkgs; [ python3 ]; }; - user = "nobody:nobody"; }; + arguemapper = self'.packages.default; + server = pkgs.writeShellApplication { + name = "server"; + text = '' + ${lib.getExe pkgs.caddy} run --config ${caddyfile} --adapter caddyfile + ''; + }; + docker = pkgs.dockerTools.buildLayeredImage { + name = "arguemapper"; + tag = "latest"; + created = "now"; + contents = [ pkgs.dockerTools.fakeNss ]; + config = { + entrypoint = [ (lib.getExe self'.packages.server) ]; + exposedPorts = { + "${caddyport}/tcp" = { }; + }; + user = "nobody:nobody"; + }; + }; + }; + legacyPackages.dockerManifest = flocken.legacyPackages.${system}.mkDockerManifest { + github = { + enable = true; + token = builtins.getEnv "GH_TOKEN"; + }; + version = builtins.getEnv "VERSION"; + images = with self.packages; [ + x86_64-linux.docker + aarch64-linux.docker + ]; }; }; - }; }; }