From 7f0e30fedda71a7347790018fd694ccf38b4790f Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 8 Nov 2023 14:21:46 +0000 Subject: [PATCH] chore: misc cleanups for flake and ci (#12) --- .github/workflows/release.yml | 7 ++++--- .github/workflows/test.yml | 2 +- flake.nix | 33 +++++++++++---------------------- test.nix | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 test.nix diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f350b5b..99a06b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,12 +4,13 @@ on: release: types: [published, edited] -permissions: - contents: write - jobs: release: runs-on: ubuntu-latest + + permissions: + contents: write + steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d66d4d1..bf96fef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,4 +38,4 @@ jobs: token: ${{ secrets.ATTIC_TOKEN }} - name: Build Nix Package - run: nix build --impure --show-trace -L .#test + run: nix-build test.nix diff --git a/flake.nix b/flake.nix index 988133f..80098a4 100644 --- a/flake.nix +++ b/flake.nix @@ -6,36 +6,25 @@ }; outputs = {nixpkgs, ...}: let - mkSystems = sys: builtins.map (arch: "${arch}-${sys}") ["x86_64" "aarch64"]; - systems = - mkSystems "linux" - ++ mkSystems "darwin"; + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; - forAllSystems = nixpkgs.lib.genAttrs systems; - nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;}); - - forEachSystem = fn: - forAllSystems (s: fn nixpkgsFor.${s}); + forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); in { - devShells = forEachSystem (pkgs: { + devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ actionlint - nodePackages.pnpm + nodejs_20 + (nodePackages_latest.pnpm.override {nodejs = nodejs_20;}) ]; }; }); - formatter = forEachSystem (p: p.alejandra); - - packages = forEachSystem (p: let - time = toString builtins.currentTime; - test = p.runCommand "test-${time}" {} '' - echo ${time} > $out - ''; - in { - inherit test; - default = test; - }); + formatter = forAllSystems (p: p.alejandra); }; } diff --git a/test.nix b/test.nix new file mode 100644 index 0000000..73debb5 --- /dev/null +++ b/test.nix @@ -0,0 +1,14 @@ +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + pkgs = import ( + fetchTarball { + url = + lock.nodes.nixpkgs.locked.url + or "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.nixpkgs.locked.rev}.tar.gz"; + sha256 = lock.nodes.nixpkgs.locked.narHash; + } + ) {}; +in + pkgs.runCommand "non-reproducible-test" {} '' + echo ${toString builtins.currentTime} > $out + ''