Skip to content

Commit 5ff69b8

Browse files
committed
Rework static-nix-tool
1 parent 0f2a6a9 commit 5ff69b8

File tree

8 files changed

+105
-75
lines changed

8 files changed

+105
-75
lines changed

nix-tools/ChangeLog.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

nix-tools/Setup.hs

Lines changed: 0 additions & 2 deletions
This file was deleted.

nix-tools/_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

nix-tools/cabal.project

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
index-state: 2023-07-16T00:00:00Z
1+
index-state: 2023-07-28T13:46:58Z
2+
3+
with-compiler: ghc-9.2.8
24

35
packages: .
46

5-
allow-newer: hackage-db:base, hackage-db:Cabal, hpack:Cabal, hnix:base, hnix:template-haskell, hnix:aeson, hnix:relude, hnix-store-core:base, hnix-store-core:memory, hnix-store-core:cryptonite, hnix-store-core:bytestring
7+
allow-newer:
8+
hackage-db:base,
9+
hackage-db:Cabal,
10+
hpack:Cabal,
11+
hnix:base,
12+
hnix:template-haskell,
13+
hnix:aeson,
14+
hnix:relude,
15+
hnix-store-core:base,
16+
hnix-store-core:memory,
17+
hnix-store-core:cryptonite,
18+
hnix-store-core:bytestring
619

720
source-repository-package
821
type: git

nix-tools/ci.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

nix-tools/flake.lock

Lines changed: 14 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix-tools/flake.nix

Lines changed: 76 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,87 @@
11
{
2-
# This is a template created by `hix init`
2+
inputs.nixpkgs.follows = "haskellNix/nixpkgs";
33
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
4-
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
5-
inputs.flake-utils.follows = "haskellNix/flake-utils";
6-
outputs = { self, nixpkgs, flake-utils, haskellNix }:
4+
5+
outputs = { nixpkgs, haskellNix, ... }:
76
let
8-
ci = (builtins.fromTOML (__readFile ./ci.toml)).dimensions;
7+
systems = [
8+
"x86_64-linux"
9+
"x86_64-darwin"
10+
# TODO switch back on when ci.iog.io has builders for aarch64-linux
11+
# "aarch64-linux"
12+
"aarch64-darwin"
13+
];
14+
15+
inherit (nixpkgs) lib;
16+
17+
# A simple thing but hard to do without screwing up lazyness.
18+
# We don't want packages.x to trigger evaluation of packages.y
19+
forEachSystem = f:
20+
let
21+
perSystem = lib.genAttrs systems f;
22+
in
23+
lib.genAttrs
24+
[ "apps" "checks" "ciJobs" "devShells" "hydraJobs" "packages" ]
25+
(attrName: lib.genAttrs systems (system: perSystem.${system}.${attrName}))
26+
;
927
in
10-
flake-utils.lib.eachSystem ci.os (system:
28+
forEachSystem (system:
1129
let
12-
compilers = builtins.filter
13-
(x: !__elem "${system}.${x}" ci.disable)
14-
(ci.compiler);
15-
overlays = [ haskellNix.overlay
16-
(final: prev: {
17-
hixProject =
18-
final.haskell-nix.hix.project {
19-
src = ./.;
20-
compiler-nix-name = __head compilers;
21-
};
22-
})
23-
];
24-
pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
25-
flake = pkgs.hixProject.flake {
26-
variants = pkgs.lib.genAttrs (__tail compilers)
27-
(x: { compiler-nix-name = pkgs.lib.mkForce x; });
30+
pkgs = haskellNix.legacyPackages.${system};
31+
32+
project = pkgs.haskell-nix.cabalProject' {
33+
src = ./.;
34+
compiler-nix-name = "ghc928";
2835
};
29-
in flake // {
30-
legacyPackages = pkgs;
31-
});
3236

33-
# --- Flake Local Nix Configuration ----------------------------
37+
mkTarball = package:
38+
let
39+
name = "${package.identifier.name}-${package.identifier.version}";
40+
paths = builtins.attrValues package.components.exes;
41+
in
42+
pkgs.runCommand name
43+
{ preferLocalBuild = true; }
44+
''
45+
mkdir -p ${name}
46+
cp --verbose --target-directory ${name} \
47+
${pkgs.lib.concatMapStringsSep " \\\n " (p: "${p}/bin/*") paths}
48+
49+
mkdir -p $out
50+
tar cvzf $out/${name}.tar.gz ${name}
51+
52+
mkdir -p $out/nix-support
53+
echo "file binary-dist $out/${name}.tar.gz" >> $out/nix-support/hydra-build-products
54+
# Propagate the release name of the source tarball. This is
55+
# to get nice package names in channels.
56+
echo "${name}" >> $out/nix-support/hydra-release-name
57+
'';
58+
in
59+
lib.recursiveUpdate
60+
project.flake'
61+
(
62+
lib.optionalAttrs (system == "x86_64-linux")
63+
{
64+
hydraJobs.binary-tarball = mkTarball
65+
project.projectCross.musl64.hsPkgs.nix-tools;
66+
}
67+
//
68+
lib.optionalAttrs (system == "aarch64-linux")
69+
{
70+
hydraJobs.binary-tarball = mkTarball
71+
project.projectCross.aarch64-multiplatform-musl.hsPkgs.nix-tools;
72+
}
73+
)
74+
);
75+
3476
nixConfig = {
35-
# This sets the flake to use the IOG nix cache.
36-
# Nix should ask for permission before using it,
37-
# but remove it here if you do not want it to.
38-
extra-substituters = ["https://cache.iog.io"];
39-
extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="];
77+
extra-substituters = [
78+
"https://cache.iog.io"
79+
"https://cache.zw3rk.com"
80+
];
81+
extra-trusted-public-keys = [
82+
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
83+
"loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk="
84+
];
4085
allow-import-from-derivation = "true";
4186
};
4287
}

nix-tools/nix-tools.cabal

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ maintainer: moritz.angermann@gmail.com
99
-- copyright:
1010
category: Distribution
1111
build-type: Simple
12-
extra-source-files: ChangeLog.md
1312
cabal-version: >=1.10
1413

1514
library
@@ -206,29 +205,18 @@ executable make-install-plan
206205
ghc-options: -Wall
207206
main-is: MakeInstallPlan.hs
208207
other-modules: Freeze
209-
-- TODO clean this up
210208
build-depends: base
211-
, aeson
212209
, bytestring
213210
, Cabal >= 3.10
214211
, cabal-install >= 3.10
215212
, cabal-install-solver >= 3.10
216213
, Cabal-syntax >= 3.10
217214
, containers
218-
, directory
219-
, extra
220215
, filepath
221216
, hnix
222-
, hpack
223-
, microlens
224-
, microlens-aeson
225217
, nix-tools
226-
, optparse-applicative
227218
, prettyprinter
228219
, text
229-
, transformers
230-
, unordered-containers
231-
, vector
232220
hs-source-dirs: make-install-plan
233221
, plan2nix
234222
default-language: Haskell2010

0 commit comments

Comments
 (0)