Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add flake #2517

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
description = "Flake for Plutus";

inputs = {
nixpkgs.url =
"github:NixOS/nixpkgs?rev=d105075a1fd870b1d1617a6008cb38b443e65433";
haskell-nix.url = "github:input-output-hk/haskell.nix";
# haskell-nix.url = "path:/home/manveru/github/input-output-hk/haskell.nix";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, haskell-nix, flake-utils, ... }:
(flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
let
sources =
let
sourcesInfo =
builtins.fromJSON (builtins.readFile ./nix/sources.json);
fetch = sourceInfo:
builtins.fetchTarball { inherit (sourceInfo) url sha256; };
in
builtins.mapAttrs (_: fetch) sourcesInfo
// { inherit nixpkgs; };
plutusPackages = import ./nix {
inherit system sources;
rev = "TODO-fix-flake-rev";
haskellNixOverlays = [ haskell-nix.overlay ];
};
inherit (plutusPackages) pkgs plutusMusl plutus ownOverlays;
in
rec {
legacyPackages = pkgs;
# overlays = ownOverlays;

packages = {
web-ghc-server = plutus.haskell.project.hsPkgs.web-ghc.components.exes.web-ghc-server;
};

devShell = import ./shell.nix { packages = plutusPackages; };

apps.web-ghc = flake-utils.lib.mkApp {
exePath = "/bin/web-ghc-server"; # This is only needed because haskell.nix exePath includes $out
drv = packages.web-ghc-server;
};
}));
}
31 changes: 17 additions & 14 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,41 @@
, config ? { }
, overlays ? [ ]
, sourcesOverride ? { }
, sources ? import ./sources.nix { }
// sourcesOverride
, haskellNix ? import sources."haskell.nix" {
sourcesOverride = {
hackage = sources."hackage.nix";
stackage = sources."stackage.nix";
};
}
, haskellNixOverlays ? haskellNix.overlays
, rev ? null
, checkMaterialization ? false
}:
let
sources = import ./sources.nix { inherit pkgs; }
// sourcesOverride;
iohkNix = import sources.iohk-nix { };
haskellNix = import sources."haskell.nix" {
sourcesOverride = {
hackage = sources."hackage.nix";
stackage = sources."stackage.nix";
};
};

extraOverlays =
# Haskell.nix (https://github.com/input-output-hk/haskell.nix)
haskellNix.overlays
ownOverlays =
# haskell-nix.haskellLib.extra: some useful extra utility functions for haskell.nix
++ iohkNix.overlays.haskell-nix-extra
iohkNix.overlays.haskell-nix-extra
# iohkNix: nix utilities and niv:
++ iohkNix.overlays.iohkNix
# our own overlays:
++ [
# Modifications to derivations from nixpkgs
(import ./overlays/nixpkgs-overrides.nix)
(import ./overlays/nixpkgs-overrides.nix { inherit sources; })
# This contains musl-specific stuff, but it's all guarded by appropriate host-platform
# checks, so we can include it unconditionally
(import ./overlays/musl.nix)
# fix r-modules
(import ./overlays/r.nix)
];

extraOverlays =
# Haskell.nix (https://github.com/input-output-hk/haskell.nix)
haskellNixOverlays ++ ownOverlays;

pkgs = import sources.nixpkgs {
inherit system crossSystem;
overlays = extraOverlays ++ overlays;
Expand All @@ -52,5 +55,5 @@ let

in
{
inherit pkgs plutusMusl plutus;
inherit pkgs plutusMusl plutus ownOverlays;
}
3 changes: 2 additions & 1 deletion nix/overlays/nixpkgs-overrides.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ sources }:
self: super: {
nix-gitignore = super.callPackage ((import ../sources.nix).nix-gitignore) { };
nix-gitignore = super.callPackage (sources.nix-gitignore) { };
# We can *nearly* replace this with upstream nixpkgs, but unfortunately we also need a patch
# that hasn't been merged upstream yet. And you can't override the pieces of a 'bundlerApp'.
asciidoctor = super.callPackage ../pkgs/asciidoctor { };
Expand Down
2 changes: 1 addition & 1 deletion nix/pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let
# `set-git-rev` is a function that can be called on a haskellPackages
# package to inject the git revision post-compile
set-git-rev = pkgs.callPackage ./set-git-rev {
inherit (haskell.packages) ghcWithPackages;
inherit (haskell.project) ghcWithPackages;
inherit git-rev;
};

Expand Down
2 changes: 1 addition & 1 deletion nix/pkgs/web-ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let
web-ghc-server = set-git-rev haskell.packages.web-ghc.components.exes.web-ghc-server;

runtimeGhc = haskell.packages.ghcWithPackages (ps: [
runtimeGhc = haskell.project.ghcWithPackages (ps: [
ps.playground-common
ps.plutus-playground-server
ps.plutus-use-cases
Expand Down
6 changes: 3 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "c583fb3e775d0f071b58a53f82f726cec623c800",
"sha256": "0pzsaxwap6jmmpcyzwvygbrfcanjzkwfrmlqac4jnjrfixd8g27s",
"rev": "180779b7f530dcd2a45c7d00541f0f3e3d8471b5",
"sha256": "0y5r0k5wmn1zcip52ifkdy8vpj252q21fzqcy1hgxq9a6n2mh3yi",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/c583fb3e775d0f071b58a53f82f726cec623c800.tar.gz",
"url": "https://github.com/input-output-hk/haskell.nix/archive/180779b7f530dcd2a45c7d00541f0f3e3d8471b5.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"iohk-nix": {
Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let
]);

in
haskell.packages.shellFor {
haskell.project.shellFor {
nativeBuildInputs = nixpkgsInputs ++ localInputs ++ [ agdaWithStdlib sphinxTools ];

# we have a local passwords store that we use for deployments etc.
Expand Down