From f3e52ede3c110222897c7035fc545fa7c3ccf938 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 2 Jun 2020 00:58:36 +0200 Subject: [PATCH 1/3] flake: remove epoch It was renamed to edition: https://github.com/NixOS/rfcs/commit/cc5d0a24970a49d7da294544aff2fb3c26139635 leading to the following error: error: flake 'git+file:///home/jtojnar/Projects/nixflk?ref=template&rev=31c2b767ca7cb901040e388794b34942807719e0' has an unsupported attribute 'epoch', at /nix/store/yndrc91vlh5vm0k4nngx303q1cjm77z9-source/flake.nix:4:3 but that itself has been deprecated: warning: flake 'git+file:///home/jtojnar/Projects/nixflk' has deprecated attribute 'edition' --- flake.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/flake.nix b/flake.nix index 8a50e026..6dbb2572 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,6 @@ { description = "A highly structured configuration database."; - epoch = 201909; - inputs.nixpkgs.url = "nixpkgs/release-20.03"; inputs.home.url = "github:nrdxp/home-manager/flakes"; From 0b14dbbc2df8dc13c4a96dac21092cc6cf8f14a1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 2 Jun 2020 01:14:33 +0200 Subject: [PATCH 2/3] flake: Refactor nixosModules collection We will want to reuse the prep method for overlays so let's move it higher and simplify it a bit. --- flake.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 6dbb2572..ce60012b 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,18 @@ inherit (nixpkgs.lib) removeSuffix; system = "x86_64-linux"; + # Generate an attribute set by mapping a function over a list of values. + genAttrs' = values: f: listToAttrs (map f values); + + # Convert a list to file paths to attribute set + # that has the filenames stripped of nix extension as keys + # and imported content of the file as value. + pathsToImportedAttrs = paths: + genAttrs' paths (path: { + name = removeSuffix ".nix" (baseNameOf path); + value = import path; + }); + pkgs = import nixpkgs { inherit system; overlays = self.overlays; @@ -33,18 +45,13 @@ }; nixosModules = let - prep = map (path: { - name = removeSuffix ".nix" (baseNameOf path); - value = import path; - }); - # modules moduleList = import ./modules/list.nix; - modulesAttrs = listToAttrs (prep moduleList); + modulesAttrs = pathsToImportedAttrs moduleList; # profiles profilesList = import ./profiles/list.nix; - profilesAttrs = { profiles = listToAttrs (prep profilesList); }; + profilesAttrs = { profiles = pathsToImportedAttrs profilesList; }; in modulesAttrs // profilesAttrs; }; From a7749005bc0d6f622cf09aafb936c55c47035e2a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 2 Jun 2020 01:17:38 +0200 Subject: [PATCH 3/3] flake: Fix overlays for `nix flake check` It complains that: value is a list while a set was expected, at /nix/store/0qdcc831rj27wz07lrri6bnfmhvm4wrm-source/flake.nix:26:7 But nixpkgs still expects a list, so we need to pass it just the values. --- flake.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index ce60012b..fe7165d8 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ outputs = inputs@{ self, home, nixpkgs }: let - inherit (builtins) listToAttrs baseNameOf attrNames readDir; + inherit (builtins) listToAttrs baseNameOf attrNames attrValues readDir; inherit (nixpkgs.lib) removeSuffix; system = "x86_64-linux"; @@ -24,7 +24,7 @@ pkgs = import nixpkgs { inherit system; - overlays = self.overlays; + overlays = attrValues self.overlays; config = { allowUnfree = true; }; }; @@ -35,10 +35,12 @@ overlay = import ./pkgs; - overlays = let - overlays = map (name: import (./overlays + "/${name}")) - (attrNames (readDir ./overlays)); - in overlays; + overlays = + let + overlayDir = ./overlays; + fullPath = name: overlayDir + "/${name}"; + overlayPaths = map fullPath (attrNames (readDir overlayDir)); + in pathsToImportedAttrs overlayPaths; packages.x86_64-linux = { inherit (pkgs) sddm-chili dejavu_nerdfont purs pure;