mirror of
https://github.com/malob/prefmanager.git
synced 2024-12-14 11:57:49 +00:00
Update to GHC 8.8.4 and switch to haskell.nix for nix builds
This commit is contained in:
parent
fa8eb3416c
commit
bdf9eae327
8 changed files with 103 additions and 66 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
.stack-work/
|
||||
*~
|
||||
.envrc
|
||||
result
|
||||
|
|
23
default.nix
23
default.nix
|
@ -1,2 +1,21 @@
|
|||
{ pkgs ? import <nixpkgs> {}}:
|
||||
pkgs.haskell.packages.ghc865.callPackage ./prefmanager.nix { }
|
||||
{ # Fetch the latest haskell.nix and import its default.nix
|
||||
haskellNix ? import (import nix/sources.nix)."haskell.nix" {}
|
||||
|
||||
# haskell.nix provides access to the nixpkgs pins which are used by our CI,
|
||||
# hence you will be more likely to get cache hits when using these.
|
||||
# But you can also just use your own, e.g. '<nixpkgs>'.
|
||||
, nixpkgsSrc ? haskellNix.sources.nixpkgs-2009
|
||||
|
||||
# haskell.nix provides some arguments to be passed to nixpkgs, including some
|
||||
# patches and also the haskell.nix functionality itself as an overlay.
|
||||
, nixpkgsArgs ? haskellNix.nixpkgsArgs
|
||||
|
||||
# import nixpkgs with overlays
|
||||
, pkgs ? import nixpkgsSrc nixpkgsArgs
|
||||
}: pkgs.haskell-nix.project {
|
||||
# 'cleanGit' cleans a source directory based on the files known by git
|
||||
src = pkgs.haskell-nix.haskellLib.cleanGit {
|
||||
name = "prefmanager";
|
||||
src = ./.;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
{
|
||||
"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": "6134e66e1decf2155ba500dd5de00adb06e2cdee",
|
||||
"sha256": "1w6mvlblszl3spx46m3a4bz13xah18gkznzpk0fzkmfizasv7lgi",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/6134e66e1decf2155ba500dd5de00adb06e2cdee.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "nixpkgs-unstable",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": null,
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fcd447bfed52b95d8e63314c0e8ab3c01649dfdc",
|
||||
"sha256": "013gvrhxvn3qpfjf0vjb3nymw8h4zmdgnvz46dvfp8cgvv0603s4",
|
||||
"rev": "502845c3e31ef3de0e424f3fcb09217df2ce6df6",
|
||||
"sha256": "0fcqpsy6y7dgn0y0wgpa56gsg0b0p8avlpjrd79fp4mp9bl18nda",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/fcd447bfed52b95d8e63314c0e8ab3c01649dfdc.tar.gz",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/502845c3e31ef3de0e424f3fcb09217df2ce6df6.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,25 +6,33 @@ let
|
|||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
||||
fetch_file = pkgs: name: spec:
|
||||
let
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
||||
|
||||
fetch_tarball = pkgs: name: spec:
|
||||
let
|
||||
ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
|
||||
# sanitize the name, though nix will still fail if name starts with period
|
||||
name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = spec:
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
||||
fetch_git = name: spec:
|
||||
let
|
||||
ref =
|
||||
if spec ? ref then spec.ref else
|
||||
if spec ? branch then "refs/heads/${spec.branch}" else
|
||||
if spec ? tag then "refs/tags/${spec.tag}" else
|
||||
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
||||
in
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
||||
|
||||
fetch_local = spec: spec.path;
|
||||
|
||||
|
@ -40,11 +48,21 @@ let
|
|||
# Various helpers
|
||||
#
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
||||
sanitizeName = name:
|
||||
(
|
||||
concatMapStrings (s: if builtins.isList s then "-" else s)
|
||||
(
|
||||
builtins.split "[^[:alnum:]+._?=-]+"
|
||||
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
||||
)
|
||||
);
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources:
|
||||
mkPkgs = sources: system:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in
|
||||
|
@ -64,9 +82,9 @@ let
|
|||
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then fetch_file pkgs spec
|
||||
else if spec.type == "file" then fetch_file pkgs name spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then fetch_git spec
|
||||
else if spec.type == "git" then fetch_git name spec
|
||||
else if spec.type == "local" then fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||
|
@ -98,25 +116,29 @@ let
|
|||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||
concatMapStrings = f: list: concatStrings (map f list);
|
||||
concatStrings = builtins.concatStringsSep "";
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
||||
optionalAttrs = cond: as: if cond then as else {};
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, name, sha256 }@attrs:
|
||||
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit name url; }
|
||||
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, sha256 }@attrs:
|
||||
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl { inherit url; }
|
||||
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
|
@ -135,7 +157,8 @@ let
|
|||
mkConfig =
|
||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, pkgs ? mkPkgs sources
|
||||
, system ? builtins.currentSystem
|
||||
, pkgs ? mkPkgs sources system
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
{ mkDerivation, async, base, containers, diffmap, hpack, hxt
|
||||
, optparse-applicative, plist, pretty-show, process, stdenv
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "prefmanager";
|
||||
version = "0.1.0.0";
|
||||
src = ./.;
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
libraryHaskellDepends = [
|
||||
async base containers diffmap hxt optparse-applicative plist
|
||||
pretty-show process
|
||||
];
|
||||
libraryToolDepends = [ hpack ];
|
||||
executableHaskellDepends = [
|
||||
async base containers diffmap hxt optparse-applicative plist
|
||||
pretty-show process
|
||||
];
|
||||
testHaskellDepends = [
|
||||
async base containers diffmap hxt optparse-applicative plist
|
||||
pretty-show process
|
||||
];
|
||||
prePatch = "hpack";
|
||||
homepage = "https://github.com/malob/prefmanager#readme";
|
||||
description = "A CLI utility for managing macOS preferences";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
with pkgs;
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
haskell.packages.ghc865.haskell-language-server
|
||||
haskell.packages.ghc884.haskell-language-server
|
||||
cabal2nix
|
||||
stack
|
||||
niv
|
||||
|
|
11
stack.yaml
11
stack.yaml
|
@ -1,9 +1,14 @@
|
|||
# GHC 8.6.5
|
||||
resolver: lts-14.21
|
||||
# GHC 8.8.4
|
||||
resolver: lts-16.17
|
||||
|
||||
packages:
|
||||
- .
|
||||
|
||||
extra-deps:
|
||||
- plist-0.0.6
|
||||
- diffmap-0.1.0.0
|
||||
# Use fork of plist package that supports MonadFail
|
||||
- github: malob/plist
|
||||
commit: 4103af23b364c101e44da115367800a2f90cc7c3
|
||||
# nix-sha256: 126c52498c89gd015p40hg671dg58j8xq8ggdqfywnkw2c8cjxxr
|
||||
|
||||
allow-newer: true
|
||||
|
|
|
@ -4,13 +4,6 @@
|
|||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages:
|
||||
- completed:
|
||||
hackage: plist-0.0.6@sha256:2c25ca88b99581ef0fe44f9d7dc636f24026603624be9c43631d2b03752886b3,1702
|
||||
pantry-tree:
|
||||
size: 463
|
||||
sha256: 92af2902f8f62e95ec57a5671267e2882cbe5092eaa36fce82172bbdb768cd7f
|
||||
original:
|
||||
hackage: plist-0.0.6
|
||||
- completed:
|
||||
hackage: diffmap-0.1.0.0@sha256:27ea8c315b5dbfb243b2c3b61eab2164534e1d02887a05392dda65995cd36c3e,727
|
||||
pantry-tree:
|
||||
|
@ -18,9 +11,20 @@ packages:
|
|||
sha256: 76ea9b9ad91d113addadf58cb19e289e84347ab667aa5c7feed0a1ccfa4ed613
|
||||
original:
|
||||
hackage: diffmap-0.1.0.0
|
||||
- completed:
|
||||
size: 4384
|
||||
url: https://github.com/malob/plist/archive/4103af23b364c101e44da115367800a2f90cc7c3.tar.gz
|
||||
name: plist
|
||||
version: 0.0.6
|
||||
sha256: fcc0a7f0dcdb81d379329f5be2af2a566431ed66cbe37e9a1f4101e49b80d4c6
|
||||
pantry-tree:
|
||||
size: 512
|
||||
sha256: 0ede20c4e670e906987a171721f05c3a3337ed936d5ff84e6fe77c13e2c7fbdf
|
||||
original:
|
||||
url: https://github.com/malob/plist/archive/4103af23b364c101e44da115367800a2f90cc7c3.tar.gz
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 524162
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/21.yaml
|
||||
sha256: 9a55dd75853718f2bbbe951872b36a3b7802fcd71796e0f25b8664f24e34c666
|
||||
original: lts-14.21
|
||||
size: 532386
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/17.yaml
|
||||
sha256: d3ee1ae797cf63189c95cf27f00700304946c5cb3c1e6a82001cd6584a221e1b
|
||||
original: lts-16.17
|
||||
|
|
Loading…
Reference in a new issue