Skip to content

Commit 18836d6

Browse files
notgne2yorickvP
authored andcommitted
Convert this project to use Nix flakes
1 parent 324c4cd commit 18836d6

7 files changed

+186
-226
lines changed

default.nix

+14-59
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,17 @@
1-
# © 2019 Serokell <hi@serokell.io>
2-
# © 2019 Lars Jellema <lars.jellema@gmail.com>
1+
# SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
32
#
43
# SPDX-License-Identifier: MPL-2.0
54

6-
{ sources ? import nix/sources.nix
7-
, nixpkgs ? sources.nixpkgs }:
8-
9-
let
10-
overlay = self: super: {
11-
haskell = super.haskell // {
12-
packageOverrides = self: super: {
13-
nixfmt = self.callCabal2nix "nixfmt" src { };
14-
};
15-
};
16-
};
17-
18-
pkgs = import nixpkgs { overlays = [ overlay ]; };
19-
20-
inherit (pkgs) haskell lib;
21-
22-
ghcjsPackages = haskell.packages.ghcjs86.override (old: {
23-
overrides = (self: super: {
24-
QuickCheck = haskell.lib.dontCheck super.QuickCheck;
25-
tasty-quickcheck = haskell.lib.dontCheck super.tasty-quickcheck;
26-
scientific = haskell.lib.dontCheck super.scientific;
27-
temporary = haskell.lib.dontCheck super.temporary;
28-
time-compat = haskell.lib.dontCheck super.time-compat;
29-
});
30-
});
31-
32-
regexes = [ ".*.cabal$" "^src.*" "^main.*" "^Setup.hs$" "^js.*" "LICENSE" ];
33-
src = builtins.path {
34-
path = ./.;
35-
name = "nixfmt-src";
36-
filter = path: type:
37-
let relPath = lib.removePrefix (toString ./. + "/") (toString path);
38-
in lib.any (re: builtins.match re relPath != null) regexes;
39-
};
40-
41-
in rec {
42-
nixfmt = pkgs.haskellPackages.nixfmt;
43-
nixfmt-static = haskell.lib.justStaticExecutables nixfmt;
44-
nixfmt-deriver = nixfmt-static.cabal2nixDeriver;
45-
nixfmt-js = ghcjsPackages.callCabal2nix "nixfmt" src { };
46-
nixfmt-webdemo = pkgs.runCommandNoCC "nixfmt-webdemo" { } ''
47-
mkdir $out
48-
cp ${./js/index.html} $out/index.html
49-
cp ${./js/404.html} $out/404.html
50-
cp ${nixfmt-js}/bin/js-interface.jsexe/{rts,lib,out,runmain}.js $out
51-
substituteInPlace $out/index.html --replace ../dist/build/js-interface/js-interface.jsexe/ ./
52-
'';
53-
54-
nixfmt-shell = nixfmt.env.overrideAttrs (oldAttrs: {
55-
buildInputs = oldAttrs.buildInputs ++ (with pkgs; [ # nixfmt: expand
56-
cabal-install
57-
stylish-haskell
58-
]);
59-
});
60-
61-
inherit (pkgs) awscli;
62-
}
5+
(import
6+
(
7+
let
8+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
9+
in
10+
fetchTarball {
11+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
12+
sha256 = lock.nodes.flake-compat.locked.narHash;
13+
}
14+
)
15+
{
16+
src = ./.;
17+
}).defaultNix

flake.lock

+60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# © 2019 Serokell <hi@serokell.io>
2+
# © 2019 Lars Jellema <lars.jellema@gmail.com>
3+
#
4+
# SPDX-License-Identifier: MPL-2.0
5+
6+
{
7+
description = "A Simple multi-profile Nix-flake deploy tool.";
8+
9+
inputs = {
10+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
11+
12+
flake-utils.url = "github:numtide/flake-utils";
13+
14+
flake-compat = {
15+
url = "github:edolstra/flake-compat";
16+
flake = false;
17+
};
18+
};
19+
20+
21+
outputs = { self, nixpkgs, flake-utils, ... }:
22+
flake-utils.lib.eachDefaultSystem (system:
23+
let
24+
overlay = self: super: {
25+
haskell = super.haskell // {
26+
packageOverrides = self: super: {
27+
nixfmt = self.callCabal2nix "nixfmt" src { };
28+
};
29+
};
30+
};
31+
32+
pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; };
33+
34+
inherit (pkgs) haskell lib;
35+
36+
ghcjsPackages = haskell.packages.ghcjs86.override (old: {
37+
overrides = (self: super: {
38+
QuickCheck = haskell.lib.dontCheck super.QuickCheck;
39+
tasty-quickcheck = haskell.lib.dontCheck super.tasty-quickcheck;
40+
scientific = haskell.lib.dontCheck super.scientific;
41+
temporary = haskell.lib.dontCheck super.temporary;
42+
time-compat = haskell.lib.dontCheck super.time-compat;
43+
});
44+
});
45+
46+
regexes = [ ".*.cabal$" "^src.*" "^main.*" "^Setup.hs$" "^js.*" "LICENSE" ];
47+
src = builtins.path {
48+
path = ./.;
49+
name = "nixfmt-src";
50+
filter = path: type:
51+
let relPath = lib.removePrefix (toString ./. + "/") (toString path);
52+
in lib.any (re: builtins.match re relPath != null) regexes;
53+
};
54+
55+
in
56+
{
57+
packages = rec {
58+
nixfmt = pkgs.haskellPackages.nixfmt;
59+
nixfmt-static = haskell.lib.justStaticExecutables nixfmt;
60+
nixfmt-deriver = nixfmt-static.cabal2nixDeriver;
61+
nixfmt-js = ghcjsPackages.callCabal2nix "nixfmt" src { };
62+
nixfmt-webdemo = pkgs.runCommandNoCC "nixfmt-webdemo" { } ''
63+
mkdir $out
64+
cp ${./js/index.html} $out/index.html
65+
cp ${./js/404.html} $out/404.html
66+
cp ${nixfmt-js}/bin/js-interface.jsexe/{rts,lib,out,runmain}.js $out
67+
substituteInPlace $out/index.html --replace ../dist/build/js-interface/js-interface.jsexe/ ./
68+
'';
69+
70+
nixfmt-shell = nixfmt.env.overrideAttrs (oldAttrs: {
71+
buildInputs = oldAttrs.buildInputs ++ (with pkgs; [
72+
# nixfmt: expand
73+
cabal-install
74+
stylish-haskell
75+
]);
76+
});
77+
78+
inherit (pkgs) awscli;
79+
};
80+
81+
apps = builtins.mapAttrs
82+
(name: p: {
83+
type = "app";
84+
program = "${p}/bin/${name}";
85+
})
86+
self.packages.${system};
87+
88+
defaultPackage = self.packages.${system}.nixfmt;
89+
defaultApp = self.apps.${system}.nixfmt;
90+
91+
devShell = self.packages.${system}.nixfmt-shell;
92+
}
93+
);
94+
}

nix/sources.json

-26
This file was deleted.

nix/sources.nix

-134
This file was deleted.

0 commit comments

Comments
 (0)