Skip to content

Commit

Permalink
make custom-config a flake. merge workbench with custom-config
Browse files Browse the repository at this point in the history
  • Loading branch information
jbgi committed May 6, 2021
1 parent c6a80c4 commit e05ba5e
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 71 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ tags
# For now require that users generate their own hie.yaml
hie.yaml

# Ignore local modification of nix config files
/custom-config.nix
/workbench-config.nix
/supported-systems.nix

# Ignore Visual Studio code configuration
.vscode/tasks.json

Expand Down
1 change: 0 additions & 1 deletion custom-config.nix

This file was deleted.

6 changes: 6 additions & 0 deletions custom-config/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
profileName = "default-mary";
autoStartCluster = false;
useCabalRun = false;
workbenchDevMode = false;
}
5 changes: 5 additions & 0 deletions custom-config/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
outputs = {...}: {
nixosModule = {};
};
}
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# allows to cutomize haskellNix (ghc and profiling, see ./nix/haskell.nix)
, config ? {}
# override scripts with custom configuration
, customConfig ? import ./custom-config.nix
, customConfig ? {}
# allows to override dependencies of the project without modifications,
# eg. to test build against local checkout of nixpkgs and iohk-nix:
# nix build -f default.nix cardano-node --arg sourcesOverride '{
Expand Down
32 changes: 9 additions & 23 deletions flake.lock

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

13 changes: 4 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
url = "github:input-output-hk/iohk-nix/flakes-improvements";
inputs.nixpkgs.follows = "nixpkgs";
};
custom-config = {
url = "path:./custom-config.nix";
flake = false;
};
workbench-config = {
url = "path:./workbench-config.nix";
flake = false;
customConfig = {
url = "path:./custom-config";
};
};

outputs = { self, nixpkgs, utils, haskellNix, iohkNix, custom-config, workbench-config, ... }:
outputs = { self, nixpkgs, utils, haskellNix, iohkNix, customConfig }:
let
inherit (haskellNix.internal) config;
inherit (nixpkgs) lib;
Expand All @@ -37,7 +32,7 @@
iohkNix.overlays.cardano-lib
iohkNix.overlays.utils
(final: prev: {
customConfig = import custom-config;
customConfig = import ./custom-config // customConfig.outputs;
gitrev = self.rev or "dirty";
commonLib = lib
// iohkNix.lib
Expand Down
18 changes: 8 additions & 10 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? {}
, customConfig ? import ./custom-config.nix
, customConfig ? {}
, sourcesOverride ? {}
, gitrev ? null
}:
let
gitrev' = if gitrev == null
then iohkNix.commitIdFromGitRepoOrZero ../.git
else gitrev;
flakeSources = let
flakeLock = (builtins.fromJSON (builtins.readFile ../flake.lock)).nodes;
compat = s: builtins.fetchGit {
Expand Down Expand Up @@ -36,13 +33,14 @@ let
++ iohkNix.overlays.utils
# our own overlays:
++ [
(pkgs: _: with pkgs; {
gitrev = gitrev';
inherit customConfig;

inherit (iohkNix) cardanoLib;
(pkgs: _: {
gitrev = if gitrev == null
then iohkNix.commitIdFromGitRepoOrZero ../.git
else gitrev;
customConfig = import ./custom-config // customConfig;
inherit (pkgs.iohkNix) cardanoLib;
# commonLib: mix pkgs.lib with iohk-nix utils and our own:
commonLib = lib // cardanoLib // iohk-nix.lib
commonLib = with pkgs; lib // cardanoLib // iohk-nix.lib
// import ./util.nix { inherit haskell-nix; }
# also expose our sources, nixpkgs and overlays
// { inherit overlays sources nixpkgs; };
Expand Down
10 changes: 4 additions & 6 deletions nix/pkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,20 @@ final: prev: with final;

cardanolib-py = callPackage ./cardanolib-py {};

scripts = lib.recursiveUpdate (import ./scripts.nix { inherit pkgs customConfig; })
(import ./scripts-submit-api.nix { inherit pkgs customConfig; });
scripts = lib.recursiveUpdate (import ./scripts.nix { inherit pkgs; })
(import ./scripts-submit-api.nix { inherit pkgs; });

dockerImage = let
defaultConfig = {
stateDir = "/data";
dbPrefix = "db";
socketPath = "/ipc/node.socket";
};
customConfig' = defaultConfig // customConfig;
in callPackage ./docker.nix {
exe = "cardano-node";
scripts = import ./scripts.nix {
inherit pkgs;
customConfig = customConfig';
customConfigs = [ defaultConfig customConfig ];
};
script = "node";
};
Expand All @@ -110,12 +109,11 @@ final: prev: with final;
defaultConfig = {
socketPath = "/ipc/node.socket";
};
customConfig' = defaultConfig // customConfig;
in callPackage ./docker.nix {
exe = "cardano-submit-api";
scripts = import ./scripts-submit-api.nix {
inherit pkgs;
customConfig = customConfig';
customConfigs = [ defaultConfig customConfig ];
};
script = "submit-api";
};
Expand Down
4 changes: 2 additions & 2 deletions nix/scripts-submit-api.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{ pkgs
, customConfig
, customConfigs ? [ pkgs.customConfig ]
}:
with pkgs.commonLib;
let
mkScript = envConfig: let
service = evalService {
inherit pkgs customConfig;
inherit pkgs customConfigs;
serviceName = "cardano-submit-api";
modules = [
./nixos/cardano-submit-api-service.nix
Expand Down
4 changes: 2 additions & 2 deletions nix/scripts.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{ pkgs
, customConfig
, customConfigs ? [ pkgs.customConfig ]
}:
with pkgs.commonLib;
let
mkScript = envConfig: let
service = evalService {
inherit pkgs customConfig;
inherit pkgs customConfigs;
serviceName = "cardano-node";
modules = [
./nixos/cardano-node-service.nix
Expand Down
8 changes: 2 additions & 6 deletions nix/workbench/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
, moreutils
, makeWrapper
, runCommand

## Default to pure Nix-iness:
, useCabalRun ? false
, workbenchDevMode ? false

, customConfig
, cardano-cli
, cardano-topology
}:

with lib;
with lib; with customConfig;

let
nixWbMode =
Expand Down
8 changes: 2 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
{ config ? {}
, sourcesOverride ? {}
, withHoogle ? true
, clusterProfile ? "default-mary"
, customConfig ? import ./custom-config.nix // { profileName = clusterProfile; }

, autoStartCluster ? false
, workbenchDevMode ? false
, customConfig ? {}
, pkgs ? import ./nix {
inherit config sourcesOverride customConfig;
}
}:
with pkgs;
with pkgs; with pkgs.customConfig;
let
commandHelp =
''
Expand Down

0 comments on commit e05ba5e

Please sign in to comment.