mirror of
https://github.com/serokell/haskell-with-utf8.git
synced 2024-09-11 06:45:36 +03:00
Convert to a proper flake
* Get rid of Niv * Repin haskell.nix * Repin nixpkgs
This commit is contained in:
parent
f26ba120c2
commit
c916ad47c3
34
default.nix
34
default.nix
@ -1,27 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
|
(import (
|
||||||
#
|
fetchTarball {
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||||
|
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||||
#
|
) {
|
||||||
# nix-flakes shim
|
src = ./.;
|
||||||
#
|
}).defaultNix
|
||||||
|
|
||||||
let
|
|
||||||
sources = builtins.removeAttrs (import ./nix/sources.nix) ["__functor"];
|
|
||||||
# https://github.com/input-output-hk/haskell.nix/blob/master/lib/override-with.nix
|
|
||||||
tryOverride = override: default:
|
|
||||||
let
|
|
||||||
try = builtins.tryEval (builtins.findFile builtins.nixPath override);
|
|
||||||
in if try.success then
|
|
||||||
builtins.trace "using search host <${override}>" try.value
|
|
||||||
else
|
|
||||||
default;
|
|
||||||
inputs = builtins.mapAttrs (name: s: import (tryOverride "flake-${name}" s)) sources;
|
|
||||||
flake = (import ./flake.nix).outputs (inputs // { self = flake; });
|
|
||||||
in
|
|
||||||
{ exposeFlake ? false }:
|
|
||||||
if exposeFlake then
|
|
||||||
flake
|
|
||||||
else {
|
|
||||||
inherit (flake.packages) with-utf8;
|
|
||||||
}
|
|
||||||
|
60
flake.lock
Normal file
60
flake.lock
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1610051610,
|
||||||
|
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"haskell-nix": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1613524507,
|
||||||
|
"narHash": "sha256-vIjgOb6PKGtLpSDbKV6J2dI4nR8SOcST1I1B+qOhsR8=",
|
||||||
|
"owner": "input-output-hk",
|
||||||
|
"repo": "haskell.nix",
|
||||||
|
"rev": "ba87ffb84bc4158ada14908bddee9df2c81ac31b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "input-output-hk",
|
||||||
|
"repo": "haskell.nix",
|
||||||
|
"rev": "ba87ffb84bc4158ada14908bddee9df2c81ac31b",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1608007629,
|
||||||
|
"narHash": "sha256-lipVFC/a2pzzA5X2ULj64je+fz1JIp2XRrB5qyoizpQ=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "f02bf8ffb9a5ec5e8f6f66f1e5544fd2aa1a0693",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "f02bf8ffb9a5ec5e8f6f66f1e5544fd2aa1a0693",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"haskell-nix": "haskell-nix",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
55
flake.nix
55
flake.nix
@ -3,31 +3,42 @@
|
|||||||
# SPDX-License-Identifier: MPL-2.0
|
# SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
{
|
{
|
||||||
edition = 201911;
|
|
||||||
|
|
||||||
description = "Get your UTF-8 IO right on the first try";
|
description = "Get your UTF-8 IO right on the first try";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, haskell-nix }:
|
inputs = {
|
||||||
let
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
pkgs = nixpkgs {
|
haskell-nix.url = "github:input-output-hk/haskell.nix/ba87ffb84bc4158ada14908bddee9df2c81ac31b";
|
||||||
overlays = haskell-nix.overlays;
|
nixpkgs.url = "github:nixos/nixpkgs/f02bf8ffb9a5ec5e8f6f66f1e5544fd2aa1a0693";
|
||||||
};
|
};
|
||||||
|
|
||||||
project = pkgs.haskell-nix.stackProject {
|
outputs = { self, nixpkgs, flake-utils, haskell-nix }:
|
||||||
src = pkgs.haskell-nix.haskellLib.cleanGit {
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
name = "with-utf8";
|
let
|
||||||
src = ./.;
|
pkgs = nixpkgs.legacyPackages.${system}.extend haskell-nix.overlay;
|
||||||
|
|
||||||
|
project = pkgs.haskell-nix.stackProject {
|
||||||
|
src = pkgs.haskell-nix.haskellLib.cleanGit {
|
||||||
|
name = "with-utf8";
|
||||||
|
src = ./.;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
with-utf8 = project.with-utf8;
|
||||||
with-utf8 = project.with-utf8;
|
in rec {
|
||||||
in {
|
packages = {
|
||||||
packages = {
|
with-utf8 = with-utf8.components.library;
|
||||||
with-utf8 = with-utf8.components.library;
|
};
|
||||||
};
|
defaultPackage = packages.with-utf8;
|
||||||
|
|
||||||
checks = {
|
checks = {
|
||||||
build = self.packages.with-utf8;
|
build = packages.with-utf8;
|
||||||
test = with-utf8.checks.with-utf8-test;
|
test = with-utf8.checks.with-utf8-test;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
apps.utf8-troubleshoot = {
|
||||||
|
type = "app";
|
||||||
|
program = "${with-utf8.components.exes.utf8-troubleshoot}/bin/utf8-troubleshoot";
|
||||||
|
};
|
||||||
|
defaultApp = apps.utf8-troubleshoot;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"haskell-nix": {
|
|
||||||
"branch": "master",
|
|
||||||
"description": "Alternative Haskell Infrastructure for Nixpkgs",
|
|
||||||
"homepage": "https://input-output-hk.github.io/haskell.nix",
|
|
||||||
"owner": "input-output-hk",
|
|
||||||
"repo": "haskell.nix",
|
|
||||||
"rev": "e9f59def792a01b9937ef0c27fe96903aa173829",
|
|
||||||
"sha256": "19384g77wd8rxpryj12m2002l7nfw3j9nv1w44j2apayj9y8sbll",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/e9f59def792a01b9937ef0c27fe96903aa173829.tar.gz",
|
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"branch": "master",
|
|
||||||
"description": "Pinned Nixpkgs tree (master follows nixos-unstable-small, only tags have stable history)",
|
|
||||||
"homepage": "",
|
|
||||||
"owner": "serokell",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "17d9bc51f6cbc37339332e9bf9e82d172c642e7c",
|
|
||||||
"sha256": "0ckvgiif2xwbrl0sd301p4nldkc3y7qpvrvag9pykswsissbhi5v",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://github.com/serokell/nixpkgs/archive/17d9bc51f6cbc37339332e9bf9e82d172c642e7c.tar.gz",
|
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: MPL-2.0
|
|
@ -1,96 +0,0 @@
|
|||||||
# This file has been generated by Niv.
|
|
||||||
|
|
||||||
# A record, from name to path, of the third-party packages
|
|
||||||
with rec
|
|
||||||
{
|
|
||||||
pkgs =
|
|
||||||
if hasNixpkgsPath
|
|
||||||
then
|
|
||||||
if hasThisAsNixpkgsPath
|
|
||||||
then import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}
|
|
||||||
else import <nixpkgs> {}
|
|
||||||
else
|
|
||||||
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {};
|
|
||||||
|
|
||||||
sources_nixpkgs =
|
|
||||||
if builtins.hasAttr "nixpkgs" sources
|
|
||||||
then sources.nixpkgs
|
|
||||||
else abort
|
|
||||||
''
|
|
||||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
|
||||||
add a package called "nixpkgs" to your sources.json.
|
|
||||||
'';
|
|
||||||
|
|
||||||
# fetchTarball version that is compatible between all the versions of Nix
|
|
||||||
builtins_fetchTarball = { url, sha256 }@attrs:
|
|
||||||
let
|
|
||||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
|
||||||
in
|
|
||||||
if lessThan nixVersion "1.12" then
|
|
||||||
fetchTarball { inherit url; }
|
|
||||||
else
|
|
||||||
fetchTarball attrs;
|
|
||||||
|
|
||||||
# fetchurl version that is compatible between all the versions of Nix
|
|
||||||
builtins_fetchurl = { url, sha256 }@attrs:
|
|
||||||
let
|
|
||||||
inherit (builtins) lessThan nixVersion fetchurl;
|
|
||||||
in
|
|
||||||
if lessThan nixVersion "1.12" then
|
|
||||||
fetchurl { inherit url; }
|
|
||||||
else
|
|
||||||
fetchurl attrs;
|
|
||||||
|
|
||||||
# A wrapper around pkgs.fetchzip that has inspectable arguments,
|
|
||||||
# annoyingly this means we have to specify them
|
|
||||||
fetchzip = { url, sha256 }@attrs: pkgs.fetchzip attrs;
|
|
||||||
|
|
||||||
# A wrapper around pkgs.fetchurl that has inspectable arguments,
|
|
||||||
# annoyingly this means we have to specify them
|
|
||||||
fetchurl = { url, sha256 }@attrs: pkgs.fetchurl attrs;
|
|
||||||
|
|
||||||
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success;
|
|
||||||
hasThisAsNixpkgsPath =
|
|
||||||
(builtins.tryEval <nixpkgs>).success && <nixpkgs> == ./.;
|
|
||||||
|
|
||||||
sources = builtins.fromJSON (builtins.readFile ./sources.json);
|
|
||||||
|
|
||||||
mapAttrs = builtins.mapAttrs or (
|
|
||||||
f: set: with builtins;
|
|
||||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
|
||||||
);
|
|
||||||
|
|
||||||
# borrowed from nixpkgs
|
|
||||||
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
|
|
||||||
callFunctionWith = autoArgs: f: args:
|
|
||||||
let
|
|
||||||
auto = builtins.intersectAttrs (functionArgs f) autoArgs;
|
|
||||||
in
|
|
||||||
f (auto // args);
|
|
||||||
|
|
||||||
getFetcher = spec:
|
|
||||||
let
|
|
||||||
fetcherName =
|
|
||||||
if builtins.hasAttr "type" spec
|
|
||||||
then builtins.getAttr "type" spec
|
|
||||||
else "builtin-tarball";
|
|
||||||
in
|
|
||||||
builtins.getAttr fetcherName {
|
|
||||||
"tarball" = fetchzip;
|
|
||||||
"builtin-tarball" = builtins_fetchTarball;
|
|
||||||
"file" = fetchurl;
|
|
||||||
"builtin-url" = builtins_fetchurl;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# NOTE: spec must _not_ have an "outPath" attribute
|
|
||||||
mapAttrs (
|
|
||||||
_: spec:
|
|
||||||
if builtins.hasAttr "outPath" spec
|
|
||||||
then abort
|
|
||||||
"The values in sources.json should not have an 'outPath' attribute"
|
|
||||||
else
|
|
||||||
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
|
|
||||||
then
|
|
||||||
spec // { outPath = callFunctionWith spec (getFetcher spec) {}; }
|
|
||||||
else spec
|
|
||||||
) sources
|
|
@ -1,3 +0,0 @@
|
|||||||
SPDX-FileCopyrightText: 2019 Nicolas Mattia
|
|
||||||
|
|
||||||
SPDX-License-Identifier: LicenseRef-MIT-nmattia
|
|
Loading…
Reference in New Issue
Block a user