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 4, 2021
1 parent a4cf2c2 commit d91b0a9
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 82 deletions.
5 changes: 0 additions & 5 deletions .gitignore
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
@@ -0,0 +1,6 @@
{
profileName = "default-mary";
autoStartCluster = false;
useCabalRun = false;
workbenchDevMode = false;
}
5 changes: 5 additions & 0 deletions custom-config/flake.nix
@@ -0,0 +1,5 @@
{
outputs = {...}: {
nixosModule = {};
};
}
2 changes: 1 addition & 1 deletion default.nix
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.

14 changes: 4 additions & 10 deletions flake.nix
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,8 +32,7 @@
iohkNix.overlays.cardano-lib
iohkNix.overlays.utils
(final: prev: {
customConfig = import custom-config;
workbenchConfig = import workbench-config;
customConfig = import ./custom-config // customConfig.outputs;
gitrev = self.rev or "dirty";
commonLib = lib
// iohkNix.lib
Expand Down
21 changes: 9 additions & 12 deletions nix/default.nix
@@ -1,15 +1,11 @@
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? {}
, customConfig ? import ./custom-config.nix
, customConfig ? {}
, sourcesOverride ? {}
, gitrev ? null
, workbenchConfig ? import ../workbench-config.nix
}:
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 @@ -37,13 +33,14 @@ let
++ iohkNix.overlays.utils
# our own overlays:
++ [
(pkgs: _: with pkgs; {
gitrev = gitrev';
inherit customConfig workbenchConfig;

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 All @@ -57,4 +54,4 @@ let
config = haskellNix.nixpkgsArgs.config // config;
};

in pkgs
in __trace "/NIX/PKGS" pkgs
12 changes: 5 additions & 7 deletions nix/pkgs.nix
Expand Up @@ -89,21 +89,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 @@ -112,12 +111,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 All @@ -129,6 +127,6 @@ final: prev: with final;

clusterTests = import ./supervisord-cluster/tests { inherit pkgs; };

workbench = callPackage ./workbench workbenchConfig;
workbench = callPackage ./workbench {};
inherit (workbench) runWorkbench runJq;
}
4 changes: 2 additions & 2 deletions nix/scripts-submit-api.nix
@@ -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
@@ -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
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
17 changes: 5 additions & 12 deletions shell.nix
Expand Up @@ -3,19 +3,12 @@
{ config ? {}
, sourcesOverride ? {}
, withHoogle ? true
, clusterProfile ? "default-mary"
, customConfig ? import ./custom-config.nix // { profileName = clusterProfile; }

, autoStartCluster ? false
, useCabalRun ? false
, workbenchDevMode ? false
, workbenchConfig ? import ./workbench-config.nix //
{ inherit useCabalRun workbenchDevMode; }
, customConfig ? {}
, pkgs ? import ./nix {
inherit config sourcesOverride customConfig workbenchConfig;
inherit config sourcesOverride customConfig;
}
}:
with pkgs;
with pkgs; with pkgs.customConfig;
let
commandHelp =
''
Expand All @@ -35,8 +28,8 @@ let
# NOTE: due to some cabal limitation,
# you have to remove all `source-repository-package` entries from cabal.project
# after entering nix-shell for cabal to use nix provided dependencies for them.
clusterCabal = mkCluster (lib.recursiveUpdate customConfig (workbenchConfig // { useCabalRun = true; }));
clusterNix = mkCluster (lib.recursiveUpdate customConfig (workbenchConfig // { useCabalRun = false; }));
clusterCabal = mkCluster (customConfig // { useCabalRun = true; });
clusterNix = mkCluster (customConfig // { useCabalRun = false; });
nixWapped = writeShellScriptBin "nix" ''
if [[ "$@" == "flake show"* ]] || [[ "$@" == "flake check"* ]]; then
echo 'Temporary override `supported-systems.nix` original content to be able to use `nix flake show|check` on dev machines (workaround for https://github.com/NixOS/nix/issues/4265)'
Expand Down
1 change: 0 additions & 1 deletion workbench-config.nix

This file was deleted.

0 comments on commit d91b0a9

Please sign in to comment.