Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update flake.nix, run CI with GitHub actions #25

Merged
merged 5 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dist/
node_modules/
/dist/
/node_modules/
/result
/result-*
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 14 additions & 14 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 43 additions & 16 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
});
};
}
7 changes: 0 additions & 7 deletions node2nix.nix

This file was deleted.

2 changes: 1 addition & 1 deletion regen-node2nix.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 0 additions & 17 deletions release.nix

This file was deleted.

6 changes: 3 additions & 3 deletions supplement.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
#!/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
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