From 226ea391caec5b3f2f112de263dd2db3a0e012f4 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 00:08:18 +0200 Subject: stockholm: provide krebs lib --- default.nix | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index 11bae7d9..c7022517 100644 --- a/default.nix +++ b/default.nix @@ -47,8 +47,20 @@ let stockholm = { inherit (eval {}) pkgs; }; - krebs = import ./krebs (current // { inherit stockholm; }); - inherit (krebs) lib; + krebs = import ./krebs (current // { inherit lib stockholm; }); + + lib = + let + lib = import ; + klib = import ./krebs/4lib { inherit lib; }; + #ulib = import (./. + "/${current-user-name}/4lib") { lib = lib // klib; }; + ulib = {}; # TODO + in + builtins // lib // klib // ulib // rec { + # TODO move this stuff + stockholm-path = ./.; + nspath = ns: p: stockholm-path + "/${ns}/${p}"; + }; # Path resolvers for common and individual files. # Example: `upath "3modules"` produces the current user's 3modules directory @@ -65,8 +77,8 @@ let stockholm = { let # Notice the ordering. Krebs packages can only depend on Nixpkgs, # whereas user packages additionally can depend on krebs packages. - kpkgs = import (kpath "5pkgs") { inherit pkgs; }; - upkgs = import (upath "5pkgs") { pkgs = pkgs // kpkgs; }; + kpkgs = import (kpath "5pkgs") { inherit lib pkgs; }; + upkgs = import (upath "5pkgs") { inherit lib; pkgs = pkgs // kpkgs; }; in kpkgs // upkgs; }; @@ -76,8 +88,10 @@ let stockholm = { # packages and modules on top of NixOS. Some of this stuff might become # useful to a broader audience, at which point it should probably be merged # and pull-requested for inclusion into NixOS/nixpkgs. - # TODO provide krebs lib, so modules don't have to import it awkwardly eval = config: import { + specialArgs = { + inherit lib; + }; modules = [ base-module config -- cgit v1.2.3 From 714a2e492270d984e8987532c247ae4caf69fce0 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 21 Oct 2015 22:29:35 +0200 Subject: stockholm: only inherit in out --- default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index c7022517..fc322cb8 100644 --- a/default.nix +++ b/default.nix @@ -44,7 +44,7 @@ let stockholm = { # Additionally, output lib and pkgs for easy access from the shell. # Notice how we're evaluating just the base module to obtain pkgs. inherit lib; - inherit (eval {}) pkgs; + inherit pkgs; }; krebs = import ./krebs (current // { inherit lib stockholm; }); @@ -62,6 +62,8 @@ let stockholm = { nspath = ns: p: stockholm-path + "/${ns}/${p}"; }; + inherit (eval {}) pkgs; + # Path resolvers for common and individual files. # Example: `upath "3modules"` produces the current user's 3modules directory kpath = lib.nspath "krebs"; -- cgit v1.2.3 From fc64fd18cb8677f08d038a086de879fd69f89b8c Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2015 00:20:16 +0200 Subject: krebs.*: make StrictHostKeyChecking configurable --- default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index fc322cb8..b261e51e 100644 --- a/default.nix +++ b/default.nix @@ -17,7 +17,8 @@ { current-date ? abort "current-date not defined" , current-host-name ? abort "current-host-name not defined" , current-user-name ? builtins.getEnv "LOGNAME" -}@current: +, StrictHostKeyChecking ? "yes" +}@args: let stockholm = { # The generated scripts to deploy (or infest) systems can be found in the @@ -47,7 +48,7 @@ let stockholm = { inherit pkgs; }; - krebs = import ./krebs (current // { inherit lib stockholm; }); + krebs = import ./krebs (args // { inherit lib stockholm; }); lib = let -- cgit v1.2.3 From abcfba84ca375f868f84188aed704be26d145221 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2015 15:15:57 +0200 Subject: stockholm: lol literate --- default.nix | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index b261e51e..c7846419 100644 --- a/default.nix +++ b/default.nix @@ -1,19 +1,3 @@ -# Welcome to the top-level default.nix of stockholm. -# -# You can discover the whole thing easily using the `get` utility, -# which can be found at http://cgit.cd.krebsco.de/get/tree/get -# To install `get` on any Nix-enabled system, use: -# -# nix-env -f /path/to/stockholm -iA pkgs.get -# -# The "current" arguments are used to provide information about the user who's -# evaluating this file. This information is used to determine which user -# namespace is to be used. Of course there's nothing trying to prevent you -# from forging this information. E.g. you could try to generate the deployment -# script for some random user's system, targeting some random host: -# -# LOGNAME=tv get krebs.deploy system=nomic target=8.8.8.8 -# { current-date ? abort "current-date not defined" , current-host-name ? abort "current-host-name not defined" , current-user-name ? builtins.getEnv "LOGNAME" @@ -21,29 +5,8 @@ }@args: let stockholm = { - # The generated scripts to deploy (or infest) systems can be found in the - # `krebs` attribute. There's also an init script, but it's in its early - # stages, not well integrated and mostly useless at the moment. :) - # - # You'll also find lib here, which is nixpkgs/lib + krebs lib, but nobody - # is really accessing this directly, as this lib gets reexported below. inherit krebs; - - # All systems of all users can be found here. - # - # /!\ Please note that `get users.${user-name}.${host-name}.system` is a - # bad idea because it will produce vast amounts of output. These are the - # actual and complete system derivations that can be installed on the - # respective host. - # - # Another thing to notice here is that other user's systems might not be - # evaluable because of missing secrets. If you _are_ able to evaluate - # another user's system, then you probably share a similar naming scheme - # for your secret files! :) inherit users; - - # Additionally, output lib and pkgs for easy access from the shell. - # Notice how we're evaluating just the base module to obtain pkgs. inherit lib; inherit pkgs; }; @@ -65,32 +28,20 @@ let stockholm = { inherit (eval {}) pkgs; - # Path resolvers for common and individual files. - # Example: `upath "3modules"` produces the current user's 3modules directory kpath = lib.nspath "krebs"; upath = lib.nspath current-user-name; - # This is the base module. Its purpose is to provide modules and - # packages, both common ones, found in krebs/ as well as the current user's, - # found in the user's namespace. base-module = { imports = map (f: f "3modules") [ kpath upath ]; nixpkgs.config.packageOverrides = pkgs: let - # Notice the ordering. Krebs packages can only depend on Nixpkgs, - # whereas user packages additionally can depend on krebs packages. kpkgs = import (kpath "5pkgs") { inherit lib pkgs; }; upkgs = import (upath "5pkgs") { inherit lib; pkgs = pkgs // kpkgs; }; in kpkgs // upkgs; }; - # The above base module is used together with a NixOS configuration to - # produce a system. Notice how stockholm really just provides additional - # packages and modules on top of NixOS. Some of this stuff might become - # useful to a broader audience, at which point it should probably be merged - # and pull-requested for inclusion into NixOS/nixpkgs. eval = config: import { specialArgs = { inherit lib; @@ -101,10 +52,6 @@ let stockholm = { ]; }; - # Any top-level directory other than krebs/ is considered to be a user - # namespace, configuring a bunch of systems. - # Have a look at the definition of install in krebs/default.nix to see how - # nix-env is using this attribute set to obtain the system to be installed. # TODO move user namespaces' to users/, so no exception for krebs/ is needed users = lib.mapAttrs @@ -113,8 +60,6 @@ let stockholm = { (n: t: !lib.hasPrefix "." n && t == "directory" && n != "krebs") (builtins.readDir ./.)); - # Given a path to a user namespace, provide an attribute of evaluated - # system configurations, keyed by system names (AKA host names). eval-all-systems = path: lib.mapAttrs' (n: _: (lib.nameValuePair (lib.removeSuffix ".nix" n) -- cgit v1.2.3 From 8f15daf2ea25304e9cbc8d449fb92078b2fb6f03 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2015 14:15:21 +0100 Subject: init krebs.current --- default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index c7846419..472d7597 100644 --- a/default.nix +++ b/default.nix @@ -31,9 +31,13 @@ let stockholm = { kpath = lib.nspath "krebs"; upath = lib.nspath current-user-name; - base-module = { + base-module = { config, ... }: { imports = map (f: f "3modules") [ kpath upath ]; + krebs.current.enable = true; + krebs.current.host = config.krebs.hosts.${current-host-name}; + krebs.current.user = config.krebs.users.${current-user-name}; + nixpkgs.config.packageOverrides = pkgs: let kpkgs = import (kpath "5pkgs") { inherit lib pkgs; }; -- cgit v1.2.3