Commit 106fc534e40e

Vincent Demeester <vincent@sbr.pm>
2023-11-02 10:59:59
nix: remove niv setup…
… and adapt the few things that were still depending on it somehow. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent ad9d088
nix/default.nix
@@ -1,16 +0,0 @@
-let
-  sources = import ./sources.nix;
-in
-rec {
-  home-manager = import (sources.home-manager + "/nixos");
-  home-manager-stable = import (sources.home-manager-stable + "/nixos");
-  lib = import (sources.nixos + "/lib");
-  pkgs = import sources.nixos;
-  lib-unstable = import (sources.nixos-unstable + "/lib");
-  pkgs-unstable = import sources.nixos-unstable;
-  nixpkgs = import sources.nixpkgs;
-  emacs = import sources.emacs-overlay;
-  gitignore = import sources.gitignore;
-  nixos-hardware = import sources.nixos-hardware;
-  sops-nix = import sources.sops-nix;
-}
nix/sources.json
@@ -1,122 +0,0 @@
-{
-    "emacs-overlay": {
-        "branch": "master",
-        "description": "Bleeding edge emacs overlay [maintainer=@adisbladis] ",
-        "homepage": "",
-        "owner": "nix-community",
-        "repo": "emacs-overlay",
-        "rev": "24a75cb77b9f7204a265528ff2d154d2299d907a",
-        "sha256": "13i2p5j2s515k59mqbygcyvz0qyma4b30xf6h36p8rwy9bpwdrhf",
-        "type": "tarball",
-        "url": "https://github.com/nix-community/emacs-overlay/archive/24a75cb77b9f7204a265528ff2d154d2299d907a.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "gitignore": {
-        "branch": "master",
-        "description": "Nix function for filtering local git sources",
-        "homepage": "",
-        "owner": "hercules-ci",
-        "repo": "gitignore",
-        "rev": "bff2832ec341cf30acb3a4d3e2e7f1f7b590116a",
-        "sha256": "0va0janxvmilm67nbl81gdbpppal4aprxzb25gp9pqvf76ahxsci",
-        "type": "tarball",
-        "url": "https://github.com/hercules-ci/gitignore/archive/bff2832ec341cf30acb3a4d3e2e7f1f7b590116a.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "home-manager": {
-        "branch": "master",
-        "description": "Manage a user environment using Nix",
-        "homepage": "https://nix-community.github.io/home-manager/",
-        "owner": "nix-community",
-        "repo": "home-manager",
-        "rev": "8d38ca886880265d523a66fe3da4d42e92ab0748",
-        "sha256": "0ndzsm6yqjn1fr9m1i90i8qvg7ydmvlxj9q84a0jz67yl8vgvg7n",
-        "type": "tarball",
-        "url": "https://github.com/nix-community/home-manager/archive/8d38ca886880265d523a66fe3da4d42e92ab0748.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "home-manager-stable": {
-        "branch": "release-21.11",
-        "description": "Manage a user environment using Nix",
-        "homepage": "https://nix-community.github.io/home-manager/",
-        "owner": "nix-community",
-        "repo": "home-manager",
-        "rev": "7244c6715cb8f741f3b3e1220a9279e97b2ed8f5",
-        "sha256": "1v0gb46whw152y56flvarg5xq7gfrr7ifbqmpgbb2rsipnjhzz81",
-        "type": "tarball",
-        "url": "https://github.com/nix-community/home-manager/archive/7244c6715cb8f741f3b3e1220a9279e97b2ed8f5.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "niv": {
-        "branch": "master",
-        "description": "Easy dependency management for Nix projects",
-        "homepage": "https://github.com/nmattia/niv",
-        "owner": "nmattia",
-        "repo": "niv",
-        "rev": "df49d53b71ad5b6b5847b32e5254924d60703c46",
-        "sha256": "1j5p8mi1wi3pdcq0lfb881p97i232si07nb605dl92cjwnira88c",
-        "type": "tarball",
-        "url": "https://github.com/nmattia/niv/archive/df49d53b71ad5b6b5847b32e5254924d60703c46.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "nixos": {
-        "branch": "nixos-21.11",
-        "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
-        "homepage": "https://github.com/NixOS/nixpkgs",
-        "owner": "NixOS",
-        "repo": "nixpkgs",
-        "rev": "7b38b03d76ab71bdc8dc325e3f6338d984cc35ca",
-        "sha256": "0g880gbkxf9n80pkz2nkf177naxf6n95qkca1ca7m9nk32gvki0f",
-        "type": "tarball",
-        "url": "https://github.com/NixOS/nixpkgs/archive/7b38b03d76ab71bdc8dc325e3f6338d984cc35ca.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "nixos-hardware": {
-        "branch": "master",
-        "description": "A collection of NixOS modules covering hardware quirks.",
-        "homepage": "",
-        "owner": "NixOS",
-        "repo": "nixos-hardware",
-        "rev": "1a0ccdbf4583ed0fce37eea7955e8ef90f840a9f",
-        "sha256": "094fs5l51ih2gm5ssg56rcryq4dybsxwi2sjhya34v8ycnpr636d",
-        "type": "tarball",
-        "url": "https://github.com/NixOS/nixos-hardware/archive/1a0ccdbf4583ed0fce37eea7955e8ef90f840a9f.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "nixos-unstable": {
-        "branch": "nixos-unstable",
-        "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
-        "homepage": "https://github.com/NixOS/nixpkgs",
-        "owner": "NixOS",
-        "repo": "nixpkgs",
-        "rev": "1ffba9f2f683063c2b14c9f4d12c55ad5f4ed887",
-        "sha256": "1zx5zvpvqrgk5mfxzmwf8gd270lz7dkfk563sccp1xlhac15cipg",
-        "type": "tarball",
-        "url": "https://github.com/NixOS/nixpkgs/archive/1ffba9f2f683063c2b14c9f4d12c55ad5f4ed887.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "nixpkgs": {
-        "branch": "nixpkgs-unstable",
-        "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
-        "homepage": "https://github.com/NixOS/nixpkgs",
-        "owner": "NixOS",
-        "repo": "nixpkgs",
-        "rev": "bd4dffcdb7c577d74745bd1eff6230172bd176d5",
-        "sha256": "18zacrykj2k5x42d0grr7g1y7xhy5ppq7j0gm3lrghwflyrdkslj",
-        "type": "tarball",
-        "url": "https://github.com/NixOS/nixpkgs/archive/bd4dffcdb7c577d74745bd1eff6230172bd176d5.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    },
-    "sops-nix": {
-        "branch": "master",
-        "description": "Atomic secret provisioning for NixOS based on sops",
-        "homepage": "",
-        "owner": "Mic92",
-        "repo": "sops-nix",
-        "rev": "c2614c4fe61943b3d280ac1892fcebe6e8eaf8c8",
-        "sha256": "1vcjqcgikmjsk3h14pb4z2fzj1ppwyv356k6a340qd48n3qnaf99",
-        "type": "tarball",
-        "url": "https://github.com/Mic92/sops-nix/archive/c2614c4fe61943b3d280ac1892fcebe6e8eaf8c8.tar.gz",
-        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
-    }
-}
nix/sources.nix
@@ -1,134 +0,0 @@
-# This file has been generated by Niv.
-let
-  #
-  # The fetchers. fetch_<type> fetches specs of type <type>.
-  #
-
-  fetch_file = pkgs: spec:
-    if spec.builtin or true then
-      builtins_fetchurl { inherit (spec) url sha256; }
-    else
-      pkgs.fetchurl { inherit (spec) url sha256; };
-
-  fetch_tarball = pkgs: spec:
-    if spec.builtin or true then
-      builtins_fetchTarball { inherit (spec) url sha256; }
-    else
-      pkgs.fetchzip { inherit (spec) url sha256; };
-
-  fetch_git = spec:
-    builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
-
-  fetch_builtin-tarball = spec:
-    builtins.trace
-      ''
-        WARNING:
-          The niv type "builtin-tarball" will soon be deprecated. You should
-          instead use `builtin = true`.
-
-          $ niv modify <package> -a type=tarball -a builtin=true
-      ''
-      builtins_fetchTarball { inherit (spec) url sha256; };
-
-  fetch_builtin-url = spec:
-    builtins.trace
-      ''
-        WARNING:
-          The niv type "builtin-url" will soon be deprecated. You should
-          instead use `builtin = true`.
-
-          $ niv modify <package> -a type=file -a builtin=true
-      ''
-      (builtins_fetchurl { inherit (spec) url sha256; });
-
-  #
-  # Various helpers
-  #
-
-  # The set of packages used when specs are fetched using non-builtins.
-  mkPkgs = sources:
-    let
-      sourcesNixpkgs =
-        import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { };
-      hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
-      hasThisAsNixpkgsPath = <nixpkgs> == ./.;
-    in
-    if builtins.hasAttr "nixpkgs" sources
-    then sourcesNixpkgs
-    else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
-      import <nixpkgs> { }
-    else
-      abort
-        ''
-          Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
-          add a package called "nixpkgs" to your sources.json.
-        '';
-
-  # The actual fetching function.
-  fetch = pkgs: name: spec:
-
-    if ! builtins.hasAttr "type" spec then
-      abort "ERROR: niv spec ${name} does not have a 'type' attribute"
-    else if spec.type == "file" then fetch_file pkgs spec
-    else if spec.type == "tarball" then fetch_tarball pkgs spec
-    else if spec.type == "git" then fetch_git spec
-    else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
-    else if spec.type == "builtin-url" then fetch_builtin-url spec
-    else
-      abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
-
-  # Ports of functions for older nix versions
-
-  # a Nix version of mapAttrs if the built-in doesn't exist
-  mapAttrs = builtins.mapAttrs or (
-    f: set: with builtins;
-    listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
-  );
-
-  # fetchTarball version that is compatible between all the versions of Nix
-  builtins_fetchTarball = { url, sha256 }@attrs:
-    let
-      inherit (builtins) lessThan nixVersion fetchTarball;
-    in
-    if lessThan nixVersion "1.12" then
-      fetchTarball { inherit url; }
-    else
-      fetchTarball attrs;
-
-  # fetchurl version that is compatible between all the versions of Nix
-  builtins_fetchurl = { url, sha256 }@attrs:
-    let
-      inherit (builtins) lessThan nixVersion fetchurl;
-    in
-    if lessThan nixVersion "1.12" then
-      fetchurl { inherit url; }
-    else
-      fetchurl attrs;
-
-  # Create the final "sources" from the config
-  mkSources = config:
-    mapAttrs
-      (
-        name: spec:
-          if builtins.hasAttr "outPath" spec
-          then abort
-            "The values in sources.json should not have an 'outPath' attribute"
-          else
-            spec // { outPath = fetch config.pkgs name spec; }
-      )
-      config.sources;
-
-  # The "config" used by the fetchers
-  mkConfig =
-    { sourcesFile ? ./sources.json
-    , sources ? builtins.fromJSON (builtins.readFile sourcesFile)
-    , pkgs ? mkPkgs sources
-    }: rec {
-      # The sources, i.e. the attribute set of spec name to spec
-      inherit sources;
-
-      # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
-      inherit pkgs;
-    };
-in
-mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }
systems/hosts/aomi.nix
@@ -20,8 +20,8 @@ in
 {
   imports = [
     ../hardware/lenovo-p1.nix
-    (import ../../users).vincent
-    (import ../../users).root
+    import ../../users/vincent
+    import ../../users/root
   ];
 
   boot.initrd.luks.devices = {
systems/hosts/k8sn1.nix
@@ -14,8 +14,8 @@ in
     (import ../../nix).home-manager-stable
     ../modules/default.stable.nix
     # FIXME Need to refactor vincent user as.. it's adding way to much by default...
-    # (import ../../../users).vincent
-    (import ../../users).root
+    
+   import ../../users/root
   ];
 
   fileSystems."/" = {
systems/hosts/k8sn2.nix
@@ -14,8 +14,8 @@ in
     (import ../../nix).home-manager-stable
     ../modules/default.stable.nix
     # FIXME Need to refactor vincent user as.. it's adding way to much by default...
-    # (import ../../../users).vincent
-    (import ../../users).root
+
+   import ../../users/root
   ];
 
   fileSystems."/" = {
systems/hosts/k8sn3.nix
@@ -14,8 +14,8 @@ in
     (import ../../nix).home-manager-stable
     ../modules/default.stable.nix
     # FIXME Need to refactor vincent user as.. it's adding way to much by default...
-    # (import ../../../users).vincent
-    (import ../../users).root
+    
+    import ../../users/root
   ];
 
   fileSystems."/" = {
systems/hosts/kerkouane.nix
@@ -67,8 +67,8 @@ in
     # (sources.nixos + "/nixos/modules/profiles/qemu-guest.nix")
     # (import ../../nix).home-manager-stable
     # ../modules/default.stable.nix
-    (import ../../users).vincent
-    (import ../../users).root
+    import ../../users/vincent
+    import ../../users/root
   ];
 
   networking.hostName = hostname;
systems/hosts/naruhodo.nix
@@ -23,8 +23,8 @@ in
     ../hardware/thinkpad-t480s.nix
     # (import ../../nix).home-manager
     # ../modules
-    (import ../../users).vincent
-    (import ../../users).root
+    import ../../users/vincent
+    import ../../users/root
   ];
 
   fileSystems."/" = {
systems/hosts/sakhalin.nix
@@ -19,8 +19,8 @@ in
     ../hardware/gigabyte-brix.nix
     # (import ../../nix).home-manager-stable
     # ../modules/default.stable.nix
-    (import ../../users).vincent
-    (import ../../users).root
+    import ../../users/vincent
+    import ../../users/root
   ];
 
   fileSystems."/" = {
systems/hosts/shikoku.nix
@@ -18,8 +18,8 @@ in
   imports = [
     # (import ../../nix).home-manager-stable
     #../modules/default.stable.nix
-    (import ../../users).vincent
-    (import ../../users).root
+    import ../../users/vincent
+    import ../../users/root
   ];
 
   boot.supportedFilesystems = [ "zfs" ];
systems/hosts/wakasu.nix
@@ -26,8 +26,10 @@ in
 {
   imports = [
     ../hardware/thinkpad-x1g9.nix
-    (import ../../users).vincent
-    (import ../../users).root
+    ../../users/vincent
+    ../../users/root
+    # (import ../../users).vincent
+    # (import ../../users).root
   ];
 
   fileSystems."/" = {
users/default.nix
@@ -1,10 +0,0 @@
-with builtins;
-let
-  lib = (import ../nix).lib;
-  userDirs = attrNames (lib.filterAttrs (_: v: v == "directory") (readDir ./.));
-  mkUser = u: import (./. + "/${u}");
-  users = lib.genAttrs userDirs mkUser;
-in
-{
-  family = with users; [ vincent houbeb ];
-} // users
ci.nix
@@ -1,71 +0,0 @@
-# FIXME: migrate this to flake somehow
-# This file provides all the buildable and cacheable packages and
-# package outputs in you package set. These are what gets built by CI,
-# so if you correctly mark packages as
-#
-# - broken (using `meta.broken`),
-# - unfree (using `meta.license.free`), and
-# - locally built (using `preferLocalBuild`)
-#
-# then your CI will be able to build and cache only those packages for
-# which this is possible.
-
-{ sources ? import ./nix
-, pkgs ? sources.pkgs { }
-, pkgs-unstable ? sources.pkgs-unstable { }
-, nixpkgs ? sources.nixpkgs { }
-}:
-
-with builtins;
-let
-  isReserved = n: n == "lib" || n == "overlays" || n == "modules";
-  isDerivation = p: isAttrs p && p ? type && p.type == "derivation";
-  isBuildable = p: !(p.meta.broken or false) && p.meta.license.free or true;
-  isCacheable = p: !(p.preferLocalBuild or false);
-  shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false;
-  nameValuePair = n: v: { name = n; value = v; };
-  concatMap = builtins.concatMap or (f: xs: concatLists (map f xs));
-  flattenPkgs = s:
-    let
-      f = p:
-        if shouldRecurseForDerivations p then flattenPkgs p
-        else if isDerivation p then [ p ]
-        else [ ];
-    in
-    concatMap f (attrValues s);
-  outputsOf = p: map (o: p.${o}) p.outputs;
-  nurAttrs = p: import ./nix/packages/default.nix { pkgs = p; };
-  nurPkgs = p:
-    flattenPkgs (
-      listToAttrs (
-        map
-          (n: nameValuePair n (nurAttrs p).${n})
-          (
-            filter
-              (n: !isReserved n)
-              (attrNames (nurAttrs p))
-          )
-      )
-    );
-  nixosNurPkgs = nurPkgs pkgs;
-  nixosUnstableNurPkgs = nurPkgs pkgs-unstable;
-  nixpkgsNurPkgs = nurPkgs nixpkgs;
-in
-rec {
-  nixosBuildPkgs = filter isBuildable nixosNurPkgs;
-  nixosCachePkgs = filter isCacheable nixosBuildPkgs;
-  nixosUnstableBuildPkgs = filter isBuildable nixosUnstableNurPkgs;
-  nixosUnstableCachePkgs = filter isCacheable nixosUnstableBuildPkgs;
-  nixpkgsBuildPkgs = filter isBuildable nixpkgsNurPkgs;
-  nixpkgsCachePkgs = filter isCacheable nixpkgsBuildPkgs;
-
-  nixosBuildOutputs = concatMap outputsOf nixosBuildPkgs;
-  nixosCacheOutputs = concatMap outputsOf nixosCachePkgs;
-  nixosUnstableBuildOutputs = concatMap outputsOf nixosUnstableBuildPkgs;
-  nixosUnstableCacheOutputs = concatMap outputsOf nixosUnstableCachePkgs;
-  nixpkgsBuildOutputs = concatMap outputsOf nixpkgsBuildPkgs;
-  nixpkgsCacheOutputs = concatMap outputsOf nixpkgsCachePkgs;
-
-  buildOuputs = nixosBuildOutputs ++ nixosUnstableBuildOutputs ++ nixpkgsBuildOutputs;
-  cacheOutputs = nixosCacheOutputs ++ nixosUnstableCacheOutputs ++ nixpkgsCacheOutputs;
-}
default.nix
@@ -1,15 +1,15 @@
-{ sources ? import ./nix
-, lib ? sources.lib
-, pkgs ? sources.pkgs { }
-, pkgs-unstable ? sources.pkgs-unstable { }
-, nixpkgs ? sources.nixpkgs { }
-}@args:
-let
-  foo = "bar";
-in
-{
-  tools.bus = pkgs.callPackage ./tools/bus { };
-  tools.univ = pkgs.callPackage ./tools/univ { };
-  tools.system = pkgs.callPackage ./tools/system { };
-  tools.k8s_infra = pkgs.callPackage ./tools/k8s.infra { };
-}
+# { sources ? import ./nix
+# , lib ? sources.lib
+# , pkgs ? sources.pkgs { }
+# , pkgs-unstable ? sources.pkgs-unstable { }
+# , nixpkgs ? sources.nixpkgs { }
+# }@args:
+# let
+#   foo = "bar";
+# in
+# {
+#   tools.bus = pkgs.callPackage ./tools/bus { };
+#   tools.univ = pkgs.callPackage ./tools/univ { };
+#   tools.system = pkgs.callPackage ./tools/system { };
+#   tools.k8s_infra = pkgs.callPackage ./tools/k8s.infra { };
+# }