From 14e72c5f239dd02234cbe467c3a4be1c0845c7cd Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 19 Aug 2021 23:33:53 +0200 Subject: Enable pure instantiation of config via flake i.e. via `nix run .#hostname`. Currently pulling in a pending pull request at jupyterWith for flakeified JupyterLab installations. The entire system consisting of `nixos_system` and `nixos_home` flakes can now be purely instantiated from clones in the user directory. No "/etc/nixos" resp. ".config/nixpkgs" needed. This is nice, probably not going to bother merging both repositories. --- flake.nix | 69 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 32 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 9569468..9861ee7 100644 --- a/flake.nix +++ b/flake.nix @@ -2,60 +2,65 @@ description = "Computing environment of Adrian Kummerlaender"; inputs = { - nixpkgs.url = github:NixOS/nixpkgs/nixos-21.05; - nixpkgs-unstable.url = github:NixOS/nixpkgs/nixpkgs-unstable; + stable.url = github:NixOS/nixpkgs/nixos-21.05; + unstable.url = github:NixOS/nixpkgs/nixpkgs-unstable; + personal.url = github:KnairdA/pkgs; home-manager = { url = github:nix-community/home-manager/release-21.05; - inputs = { nixpkgs.follows = "nixpkgs"; }; + inputs = { nixpkgs.follows = "stable"; }; }; emacs.url = github:nix-community/emacs-overlay/master; - personal = { - url = https://pkgs.kummerlaender.eu/nixexprs.tar.xz; - flake = false; - }; - jupyter = { - url = github:tweag/jupyterWith; - flake = false; - }; + jupyter.url = github:GTrunSec/jupyterWith/flakes; }; outputs = { - self, nixpkgs, nixpkgs-unstable, emacs, home-manager, personal, jupyter, ... + self, stable, unstable, personal, emacs, home-manager, jupyter, ... }: let system = "x86_64-linux"; - pkgs = import nixpkgs { + pkgs-unstable = import unstable { inherit system; config = { allowUnfree = true; }; + overlays = [ emacs.overlay ]; }; - home = home-manager.lib.homeManagerConfiguration { - configuration = { pkgs, ... }: { - _module.args = { - pkgs-personal = import personal { }; - pkgs-unstable = import nixpkgs-unstable { - inherit system; - config = { allowUnfree = true; }; - overlays = [ emacs.overlay ]; - }; - jupyter = import jupyter { }; - }; + pkgs-personal = personal; + + jupyter-overlay = (final: prev: { + jupyterWith = jupyter.defaultPackage."${final.system}"; + }); + + config = hostname: home-manager.lib.homeManagerConfiguration { + system = system; + homeDirectory = "/home/common"; + username = "common"; + extraSpecialArgs = { + inherit pkgs-unstable; + inherit pkgs-personal; + inherit hostname; + }; + configuration = { ... }: { imports = [ ./home.nix ]; nixpkgs = { config = { allowUnfree = true; }; + overlays = [ jupyter-overlay ]; }; }; - system = system; - homeDirectory = "/home/common"; - username = "common"; }; + hostnames = builtins.map + (h: builtins.replaceStrings [ ".nix" ] [ "" ] h) + (stable.lib.mapAttrsToList (name: type: name) (builtins.readDir ./host)); + in { - defaultPackage.x86_64-linux = home.activationPackage; + packages.x86_64-linux = builtins.listToAttrs + (map (h: { name = h; value = (config h).activationPackage; }) hostnames); - defaultApp.x86_64-linux = { - type = "app"; - program = "${home.activationPackage}/activate"; - }; + apps.x86_64-linux = builtins.listToAttrs + (map (h: { name = h; value = { + type = "app"; + program = "${(config h).activationPackage}/activate"; + }; + }) hostnames); }; } -- cgit v1.2.3