Skip to content

Commit

Permalink
Incorporate Nix Friday Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
David Arnold committed Oct 9, 2020
1 parent 5a24b56 commit f14806c
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 54 deletions.
5 changes: 4 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
}:
import nixpkgs {
inherit system;
overlays = [ (import ./overlay.nix) ];
overlays = [
(import ./overlay.nix)
(import ./extensions/overlay.nix)
];
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{ lib, pkgs, config }:
{ lib, pkgs, config, ... }:
with lib;
let
inherit (config)
name
dev-ca-path
static-dns
dev-ca-path
;

installProjectCA = {
name = "ca-install";
help = "install dev CA";
Expand Down Expand Up @@ -54,11 +56,52 @@ let
'';
};
in
(
if static-dns == null || static-dns == "" then [ ]
else [ fqdnsActivate fqdnsDeactivate ]
) ++
(
if dev-ca-path == null || dev-ca-path == "" then [ ]
else [ installProjectCA uninstallProjectCA ]
)
{
options = {
dev-ca-path = mkOption {
type = types.str;
default = "";
description = ''
Path to a development CA.
Users can load/unload this dev CA easily and cleanly into their local
trust stores via a wrapper around mkcert third party tool so that browsers
and other tools would accept issued certificates under this CA as valid.
Use cases:
- Ship static dev certificates under version control and make them trusted
on user machines: add the rootCA under version control alongside the
your dev certificates.
- Provide users with easy and reliable CA bootstrapping through the mkcert
command: exempt this path from version control via .gitignore and have
users easily and reliably bootstrap a dev CA infrastructure on first use.
'';
};
static-dns = mkOption {
type = types.attrs;
default = { };
description = ''
A list of static DNS entries, for which to enable instrumentation.
Users can enable/disable listed static DNS easily and cleanly
via a wrapper around the hostctl third party tool.
'';
example = {
"test.domain.local" = "172.0.0.1";
"shared.domain.link-local" = "169.254.0.5";
};
};
};
config = {
commands =
(
if static-dns == null || static-dns == "" then [ ]
else [ fqdnsActivate fqdnsDeactivate ]
) ++
(
if dev-ca-path == null || dev-ca-path == "" then [ ]
else [ installProjectCA uninstallProjectCA ]
);
};
}

5 changes: 5 additions & 0 deletions extensions/overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
final: prev:
{
hostctl = prev.callPackage ./hostctl { };
}

42 changes: 1 addition & 41 deletions mkDevShell/options.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{ lib, pkgs, config, ... }:
with lib;
let
instrumentedCommands = import ./instrumentation.nix { inherit lib pkgs config; };

resolveKey = key:
let
attrs = builtins.filter builtins.isString (builtins.split "\\." key);
Expand Down Expand Up @@ -139,27 +137,6 @@ in
'';
};

# exclusively consumed by command instrumentation
dev-ca-path = mkOption {
type = types.str;
default = "";
description = ''
Path to a development CA.
Users can load/unload this dev CA easily and cleanly into their local
trust stores via a wrapper around mkcert third party tool so that browsers
and other tools would accept issued certificates under this CA as valid.
Use cases:
- Ship static dev certificates under version control and make them trusted
on user machines: add the rootCA under version control alongside the
your dev certificates.
- Provide users with easy and reliable CA bootstrapping through the mkcert
command: exempt this path from version control via .gitignore and have
users easily and reliably bootstrap a dev CA infrastructure on first use.
'';
};

commands = mkOption {
type = types.listOf (types.submodule { options = commandOptions; });
default = [ ];
Expand Down Expand Up @@ -233,23 +210,6 @@ in
'';
};

# exclusively consumed by command instrumentation
static-dns = mkOption {
type = types.attrs;
default = { };
description = ''
A list of static DNS entries, for which to enable instrumentation.
Users can enable/disable listed static DNS easily and cleanly
via a wrapper around the hostctl third party tool.
'';
example = {
"test.domain.local" = "172.0.0.1";
"shared.domain.link-local" = "169.254.0.5";
};
};


};

config = {
Expand All @@ -263,7 +223,7 @@ in
DEVSHELL_MENU
'';
}
] ++ instrumentedCommands;
];

packages =
lib.unique (
Expand Down
1 change: 0 additions & 1 deletion overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ final: prev:
{
devshell = prev.callPackage ./devshell { };
mkDevShell = prev.callPackage ./mkDevShell { };
hostctl = prev.callPackage ./hostctl { };
}
7 changes: 6 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env nix-build
# Used to test the shell
{ pkgs ? import ./. { } }:
pkgs.mkDevShell.fromTOML ./devshell.toml
pkgs.mkDevShell {
imports = [
(pkgs.mkDevShell.importTOML ./devshell.toml)
./extensions/hoststate-instrumentation.nix
];
}

0 comments on commit f14806c

Please sign in to comment.