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

Nix improvements #167

Merged
merged 6 commits into from
Mar 19, 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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
- uses: cachix/install-nix-action@v26

- name: reuse lint
run: nix shell .#packages.x86_64-linux.reuse -c reuse lint
run: nix-build -A packages.reuse && result/bin/reuse lint

- name: build nixfmt
run: nix build -L .#nixfmt-static
run: nix-build
if: success() || failure()
59 changes: 24 additions & 35 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,39 @@ let

inherit (pkgs) haskell lib;

regexes = [
".*.cabal$"
"^src.*"
"^main.*"
"^Setup.hs$"
"^js.*"
"LICENSE"
];
src = builtins.path {
path = ./.;
name = "nixfmt-src";
filter =
path: type:
let
relPath = lib.removePrefix (toString ./. + "/") (toString path);
in
lib.any (re: builtins.match re relPath != null) regexes;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./nixfmt.cabal
./src
./main
./LICENSE
];
};

build = pkgs.haskellPackages.nixfmt;
build = lib.pipe pkgs.haskellPackages.nixfmt [
haskell.lib.justStaticExecutables
haskell.lib.dontHaddock
(drv: lib.lazyDerivation { derivation = drv; })
];
in
build
// rec {
// {
packages = {
nixfmt = build;
nixfmt-static = haskell.lib.justStaticExecutables packages.nixfmt;
nixfmt-deriver = packages.nixfmt-static.cabal2nixDeriver;

nixfmt-shell = packages.nixfmt.env.overrideAttrs (oldAttrs: {
buildInputs =
oldAttrs.buildInputs
++ (with pkgs; [
# nixfmt: expand
cabal-install
stylish-haskell
shellcheck
npins
]);
});

inherit (pkgs) reuse;
};

shell = packages.nixfmt-shell;
shell = pkgs.haskellPackages.shellFor {
packages = p: [ p.nixfmt ];
nativeBuildInputs = with pkgs; [
cabal-install
stylish-haskell
haskellPackages.haskell-language-server
shellcheck
npins
];
};

checks = {
hlint = pkgs.build.haskell.hlint ./.;
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

apps.default = {
type = "app";
program = "${self.packages.${system}.nixfmt-static}/bin/nixfmt";
program = "${result}/bin/nixfmt";
};

checks = result.checks;
Expand Down