Add examples
commit8a6795113c6ac2cff820bc5e442af4694abd88a8
authorDmitry Bushev <bushevdv@gmail.com>
dateWed 17 Jan 2018, 21:50 (9 years ago)
parent2a6c3ec
README.md+31−2
@@ -1,6 +1,6 @@
1−# Nix
1+# nixpkgs-stackage
22
3−Nixpgs overlay
3+Nixpkgs overlay with Haskell Stackage packages
44
55## Packages
66
@@ -38,4 +38,33 @@ Update script will add missing lts releases to `stackage` directory:
3838./update.sh
3939```
4040
41+# Examples
42+
43+Build derivation example for `stackage2nix` source repo.
44+
45+``` nix
46+let
47+ nixpkgs = import <nixpkgs> {
48+ overlays = [ (import ../default.nix) ];
49+ };
50+ inherit (nixpkgs) pkgs lib;
51+
52+ stackage2nixSrc = pkgs.fetchFromGitHub (lib.importJSON ./stackage2nix.json);
53+
54+ stackage = nixpkgs.haskell.packages.stackage.lib.callStackage2nix "schematic" stackage2nixSrc {
55+ inherit nixpkgs;
56+ };
57+in
58+ stackage.stackage2nix
59+```
60+
61+Build:
62+
63+```
64+nix-bulid example.nix
65+```
66+
67+See [examples](./examples) directory for more
68+
69+
4170[stackage2nix]: https://github.com/typeable/stackage2nix
examples/example-override-pinned.nixnew file+14
@@ -0,0 +1,14 @@
1+let
2+ nixpkgs = import ./nixpkgs-pinned.nix {};
3+ inherit (nixpkgs) pkgs lib haskell;
4+
5+ stackage2nixSrc = pkgs.fetchFromGitHub (lib.importJSON ./stackage2nix.json);
6+
7+ stackagePackages = haskell.packages.stackage.lib.callStackage2nix "stackage2nix" stackage2nixSrc { inherit nixpkgs; };
8+ stackage = stackagePackages.override {
9+ overrides = self: super: {
10+ stackage2nix = haskell.lib.disableSharedExecutables super.stackage2nix;
11+ };
12+ };
13+in
14+ stackage.stackage2nix
examples/example-override.nixnew file+18
@@ -0,0 +1,18 @@
1+let
2+ _pkgs = import <nixpkgs> {};
3+ _stackageOverlay = _pkgs.fetchFromGitHub (_pkgs.lib.importJSON ./nixpkgs-stackage.json);
4+ nixpkgs = import <nixpkgs> {
5+ overlays = [ (import _stackageOverlay) ];
6+ };
7+ inherit (nixpkgs) pkgs lib haskell;
8+
9+ stackage2nixSrc = pkgs.fetchFromGitHub (lib.importJSON ./stackage2nix.json);
10+
11+ stackagePackages = haskell.packages.stackage.lib.callStackage2nix "stackage2nix" stackage2nixSrc { inherit nixpkgs; };
12+ stackage = stackagePackages.override {
13+ overrides = self: super: {
14+ stackage2nix = haskell.lib.disableSharedExecutables super.stackage2nix;
15+ };
16+ };
17+in
18+ stackage.stackage2nix
examples/example.nixnew file+13
@@ -0,0 +1,13 @@
1+let
2+ nixpkgs = import <nixpkgs> {
3+ overlays = [ (import ../default.nix) ];
4+ };
5+ inherit (nixpkgs) pkgs lib;
6+
7+ stackage2nixSrc = pkgs.fetchFromGitHub (lib.importJSON ./stackage2nix.json);
8+
9+ stackage = nixpkgs.haskell.packages.stackage.lib.callStackage2nix "stackage2nix" stackage2nixSrc {
10+ inherit nixpkgs;
11+ };
12+in
13+ stackage.stackage2nix
examples/nixpkgs-pinned.nixnew file+15
@@ -0,0 +1,15 @@
1+# Nixpkgs with Stackage overlay pinned to specific version set in `nixpkgs.json`
2+
3+{ overlays ? []
4+, system ? null
5+, config ? { } }:
6+
7+let
8+ _pkgs = import <nixpkgs> {};
9+ _pkgsPath = _pkgs.fetchFromGitHub (_pkgs.lib.importJSON ./nixpkgs.json);
10+ _stackageOverlayPath = _pkgs.fetchFromGitHub (_pkgs.lib.importJSON ./nixpkgs-stackage.json);
11+in
12+ import _pkgsPath ({
13+ overlays = [ (import _stackageOverlayPath) ] ++ overlays;
14+ config = config // { allowUnfree = true; };
15+ } // (if system != null then { inherit system; } else { }))
examples/nixpkgs-stackage.jsonnew file+6
@@ -0,0 +1,6 @@
1+{
2+ "owner": "4e6",
3+ "repo": "nixpkgs-stackage",
4+ "rev": "2a6c3ecb5f0015491e2a6626d5c89aec2d75defc",
5+ "sha256": "1065v9pyi9c30qb7rq0wfpdixwn5kv0h4dziabppy406grxpmrg4"
6+}
examples/nixpkgs.jsonnew file+6
@@ -0,0 +1,6 @@
1+{
2+ "owner": "NixOS",
3+ "repo": "nixpkgs-channels",
4+ "rev": "66b4de79e3841530e6d9c6baf98702aa1f7124e4",
5+ "sha256": "1l3lwi944hnxka0nfq9a1g86xhc0b8hzqr2fm6cvds33gj26l0g4"
6+}
examples/stackage2nix.jsonnew file+6
@@ -0,0 +1,6 @@
1+{
2+ "owner": "typeable",
3+ "repo": "stackage2nix",
4+ "rev": "7bd086b41252e293af1b3d8a15e6b53bc63230bf",
5+ "sha256": "06hyma8cxncv2l6icdaf2dwh2mxjbgds6l2z2x8kp25gq2qlqx1r"
6+}