From af5bd69986bcd7f4e848968f9e365eca1e8b2340 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Tue, 25 Jun 2024 11:03:36 +0800 Subject: [PATCH 1/5] Update flake.nix --- flake.lock | 28 +++++++++++----------- flake.nix | 59 ++++++++++++++++++++++++++++++++++------------- node2nix.nix | 7 ------ regen-node2nix.sh | 2 +- release.nix | 17 -------------- 5 files changed, 58 insertions(+), 55 deletions(-) delete mode 100644 node2nix.nix delete mode 100644 release.nix diff --git a/flake.lock b/flake.lock index 15e489e..812377c 100644 --- a/flake.lock +++ b/flake.lock @@ -2,39 +2,39 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1628199198, - "narHash": "sha256-DkMFcm5VdqbausjUjyHWGBlcXNw/EMFiQpiCY5KKtMo=", + "lastModified": 1719145550, + "narHash": "sha256-K0i/coxxTEl30tgt4oALaylQfxqbotTSNb1/+g+mKMQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "439b1605227b8adb1357b55ce8529d541abbe9eb", + "rev": "e4509b3a560c87a8d4cb6f9992b8915abf9e36d8", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-unstable", "type": "indirect" } }, - "nixpkgsOld": { + "node2nix": { "flake": false, "locked": { - "lastModified": 1522825351, - "narHash": "sha256-jtxfSXmc07z8U3l0+TuUCSHcd8BgkapvUzjUN7fwZEI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "120b013e0c082d58a5712cde0a7371ae8b25a601", + "lastModified": 1664397553, + "narHash": "sha256-361KP3ys806YgwVIeXw6CrQmdV2ldJ3u95rcZUbI5vY=", + "owner": "svanderburg", + "repo": "node2nix", + "rev": "a6041f67b8d4a300c6f8d097289fe5addbc5edf8", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "18.03", - "type": "indirect" + "owner": "svanderburg", + "repo": "node2nix", + "rev": "a6041f67b8d4a300c6f8d097289fe5addbc5edf8", + "type": "github" } }, "root": { "inputs": { "nixpkgs": "nixpkgs", - "nixpkgsOld": "nixpkgsOld" + "node2nix": "node2nix" } } }, diff --git a/flake.nix b/flake.nix index 7b623f8..baa6436 100644 --- a/flake.nix +++ b/flake.nix @@ -1,21 +1,48 @@ { - inputs = { + description = "bower2nix: Generate nix expressions to fetch bower dependencies"; - nixpkgs.url = "nixpkgs/nixos-unstable"; + inputs.node2nix.url = "github:svanderburg/node2nix/a6041f67b8d4a300c6f8d097289fe5addbc5edf8"; + inputs.node2nix.flake = false; - nixpkgsOld.url = "nixpkgs/18.03"; - nixpkgsOld.flake = false; - }; + outputs = { self, nixpkgs, node2nix }: let + supportedSystems = nixpkgs.lib.systems.flakeExposed; + forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: (forSystem system f)); + forSystem = system: f: f rec { + inherit system; + pkgs = import nixpkgs { + inherit system; + overlays = [ + self.overlays.bower2nix + self.overlays.node2nix + ]; + }; + lib = pkgs.lib; + }; + in { + overlays.default = self.overlays.bower2nix; + overlays.bower2nix = final: prev: let + build = final.callPackage ./. {}; + in { + bower2nix = build.package.overrideAttrs (attrs: { + installPhase = '' + ${attrs.installPhase} + npm run prepare + cp -r dist $out + ''; + passthru = attrs.passthru or {} // build; + }); + }; + overlays.node2nix = final: prev: { + node2nix = (final.callPackage node2nix {}).package; + }; - outputs = inp: let - supportedSystems = [ "x86_64-linux" ]; - lib = inp.nixpkgs.lib; - in - lib.foldl' lib.recursiveUpdate {} (lib.forEach supportedSystems (system: - let - pkgsOld = import inp.nixpkgsOld { inherit system; }; - in - { - packages."${system}".bower2nix = pkgsOld.nodePackages.bower2nix; - })); + packages = forAllSystems ({ pkgs, system, ... }: { + inherit (pkgs) bower2nix node2nix; + default = self.packages.${system}.bower2nix; + }); + devShells = forAllSystems ({ pkgs, system, ... }: { + bower2nix = pkgs.bower2nix.shell; + default = self.devShells.${system}.bower2nix; + }); + }; } diff --git a/node2nix.nix b/node2nix.nix deleted file mode 100644 index 7b123f1..0000000 --- a/node2nix.nix +++ /dev/null @@ -1,7 +0,0 @@ -with import {}; - -let - commit = "a6041f67b8d4a300c6f8d097289fe5addbc5edf8"; - node2nixSrc = fetchTarball "https://github.com/svanderburg/node2nix/archive/${commit}.tar.gz"; -in - (callPackage node2nixSrc {}).package diff --git a/regen-node2nix.sh b/regen-node2nix.sh index f615ad0..2ebe9e3 100755 --- a/regen-node2nix.sh +++ b/regen-node2nix.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -$(nix-build node2nix.nix)/bin/node2nix --lock package-lock.json --supplement-input supplement.json --nodejs-14 +nix shell .#node2nix --command node2nix --lock package-lock.json --supplement-input supplement.json --nodejs-14 diff --git a/release.nix b/release.nix deleted file mode 100644 index 8e34463..0000000 --- a/release.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs ? - let - hash = "f42a45c015f28ac3beeb0df360e50cdbf495d44b"; - url = "https://github.com/NixOS/nixpkgs/archive/${hash}.tar.gz"; - in - import (fetchTarball url) {} -}: -let - bower2nix = (pkgs.callPackage ./. {}).package.overrideAttrs (attrs: { - installPhase = '' - ${attrs.installPhase} - npm run prepare - cp -r dist $out - ''; - }); -in - bower2nix From 74b021afac414d882c9b58c927487d675c07f32f Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Tue, 25 Jun 2024 12:57:17 +0800 Subject: [PATCH 2/5] Update .gitignore --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1eae0cf..0739517 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -dist/ -node_modules/ +/dist/ +/node_modules/ +/result +/result-* From da6e0433430949d500ac8c16c4b0aa01dc1811d0 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Tue, 25 Jun 2024 12:57:38 +0800 Subject: [PATCH 3/5] Add GitHub actions --- .github/workflows/test.yml | 16 ++++++++++++++++ .travis.yml | 5 ----- README.md | 2 -- tests/run.sh | 10 +--------- 4 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7386d4c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: "Test" +on: + pull_request: + push: +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - run: nix build + - run: nix flake check + - run: nix develop --command tsc + - run: nix shell --command tests/run.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 11d31aa..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: nix -script: ./tests/run.sh -env: - - CHANNEL=nixos-17.09 - - CHANNEL=nixos-unstable diff --git a/README.md b/README.md index 88d8ab4..1e5b3d0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # bower2nix -[![Build Status](https://travis-ci.org/rvl/bower2nix.svg?branch=master)](https://travis-ci.org/rvl/bower2nix) - Generate nix expressions to fetch bower dependencies. ## Usage diff --git a/tests/run.sh b/tests/run.sh index 49d41a3..7a04915 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,15 +1,7 @@ #!/usr/bin/env bash -export NIX_PATH="nixpkgs=https://nixos.org/channels/${CHANNEL-nixos-unstable}/nixexprs.tar.xz" - cd $(dirname $0) -nix-shell ../default.nix -A shell --run "cd .. && tsc" - -bower2nix=$(nix-build --no-out-link ../default.nix -A package) - -PATH=$bower2nix/bin:$PATH - for tst in *.json; do echo "Testing bower2nix ${tst}" bower2nix ${tst} ${tst%.*}.nix @@ -17,5 +9,5 @@ done for tst in *.json; do name=${tst%.*} - nix-build --out-link $name --argstr name $name assemble.nix + nix-build -I "nixpkgs=https://nixos.org/channels/${CHANNEL-nixos-unstable}/nixexprs.tar.xz" --out-link $name --argstr name $name assemble.nix done From fce63d35011deb3571f95423e750db81dd9b5f1c Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Tue, 25 Jun 2024 13:28:45 +0800 Subject: [PATCH 4/5] Add .gitattributes for auto-generated files --- .gitattributes | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a160288 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +package-lock.json linguist-generated=true +flake.lock linguist-generated=true +default.nix linguist-generated=true +node-env.nix linguist-generated=true +node-packages.nix linguist-generated=true +supplement.nix linguist-generated=true From 7bbb2a1f397cdfccc957940d20e76e14296aaf62 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Tue, 25 Jun 2024 13:49:46 +0800 Subject: [PATCH 5/5] Regenerate node2nix --- supplement.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/supplement.nix b/supplement.nix index f1454c7..310601a 100644 --- a/supplement.nix +++ b/supplement.nix @@ -9,10 +9,10 @@ in typescript = nodeEnv.buildNodePackage { name = "typescript"; packageName = "typescript"; - version = "4.9.3"; + version = "5.5.2"; src = fetchurl { - url = "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz"; - sha512 = "CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA=="; + url = "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz"; + sha512 = "NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew=="; }; buildInputs = globalBuildInputs; meta = {