Skip to content

Commit

Permalink
nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Jan 26, 2021
1 parent 550eb5e commit dbf4a33
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 2 deletions.
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.

64 changes: 64 additions & 0 deletions flake.nix
@@ -0,0 +1,64 @@
{
description = "Cardano Node";

inputs = {
haskell-nix.url = "github:input-output-hk/haskell.nix";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.09";
utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, utils, haskell-nix, ... }:
(utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
let
legacyPackages = import ./nix {
inherit system;
ownHaskellNix = haskell-nix.legacyPackages.${system};
gitrev = self.rev or "dirty";
};

lib = nixpkgs.lib;
sources = import ./nix/sources.nix { };
iohkNix = import sources.iohk-nix { inherit system; };
environments = iohkNix.cardanoLib.environments;
environmentName = "testnet";

eachEnv = lib.flip lib.pipe [
(lib.forEach (builtins.attrNames environments))
lib.listToAttrs
];

config = env:
{ pkgs, ... }: {
services.cardano-node = rec {
enable = true;
package = pkgs.cardano-node;
environment = env;
cardanoNodePkgs = pkgs;
stateDir = "/local";
hostAddr = "0.0.0.0";
port = 3001;
};
};

evaluated = env:
lib.nixosSystem {
inherit system;
pkgs = legacyPackages;
modules = [ ./nix/nixos/cardano-node-service.nix (config env) ];
};

packages = eachEnv (env:
lib.nameValuePair "cardano-node-${env}"
(legacyPackages.writeShellScriptBin "cardano-node-entrypoint" ''
${(evaluated env).config.services.cardano-node.script}
''));
in {
inherit environments evaluated legacyPackages packages;

apps = eachEnv (env:
lib.nameValuePair "cardano-node-${env}" (utils.lib.mkApp {
drv = packages."cardano-node-${env}";
exePath = "/bin/cardano-node-entrypoint";
}));
}));
}
5 changes: 3 additions & 2 deletions nix/default.nix
Expand Up @@ -3,12 +3,13 @@
, config ? {}
, sourcesOverride ? {}
, gitrev ? null
, ownHaskellNix ? null
}:
let
sources = import ./sources.nix { inherit pkgs; }
// sourcesOverride;
iohkNixMain = import sources.iohk-nix {};
haskellNix = (import sources."haskell.nix" { inherit system sourcesOverride; }).nixpkgsArgs;
iohkNixMain = import sources.iohk-nix { inherit system; };
haskellNix = if ownHaskellNix != null then ownHaskellNix else (import sources."haskell.nix" { inherit system sourcesOverride; }).nixpkgsArgs;
# use our own nixpkgs if it exists in our sources,
# otherwise use iohkNix default nixpkgs.
nixpkgs = if (sources ? nixpkgs)
Expand Down

0 comments on commit dbf4a33

Please sign in to comment.