From ee9b4adfc880eff8ffd038c1d64b2c535a68f141 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Fri, 28 May 2021 15:07:11 -0500 Subject: [PATCH] ref: non-flake compatibility since this is purely a legacy concern (both default.nix and shell.nix), we avoid to include the flake-compat as a flake input. (even though unused inputs are lazily fetched - for style & clarity) --- default.nix | 8 ++++++++ examples/default.nix | 2 +- flake.lock | 35 +++++++++-------------------------- flake.nix | 19 +++++-------------- lib/compat.nix | 21 +++++---------------- shell.nix | 19 +++++++------------ tests/default.nix | 2 +- 7 files changed, 36 insertions(+), 70 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..4ac6bdb --- /dev/null +++ b/default.nix @@ -0,0 +1,8 @@ +{ system ? builtins.currentSystem }: +let +in ( + (import ./lib/compat.nix).flake-compat { + src = ./.; + inherit system; + } +).defaultNix diff --git a/examples/default.nix b/examples/default.nix index 3e0ee9d..555009e 100644 --- a/examples/default.nix +++ b/examples/default.nix @@ -1,4 +1,4 @@ -{ kubenix ? import ./.. { } }: +{ kubenix ? (import ./.. { }).default }: { nginx-deployment = import ./nginx-deployment { inherit kubenix; }; diff --git a/flake.lock b/flake.lock index 0d5cc97..f93eb40 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "devshell-flake": { "locked": { - "lastModified": 1620641550, - "narHash": "sha256-o359KdI/LNiPL6EbirONff2MOvZHtZr9MgYx3R9oVFk=", + "lastModified": 1622013274, + "narHash": "sha256-mK/Lv0lCbl07dI5s7tR/7nb79HunKnJik3KyR6yeI2k=", "owner": "numtide", "repo": "devshell", - "rev": "a47493423092f6c4c0a7eb605a7cd515a77db4a8", + "rev": "e7faf69e6bf8546517cc936c7f6d31c7eb3abcb2", "type": "github" }, "original": { @@ -15,29 +15,13 @@ "type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1606424373, - "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { "locked": { - "lastModified": 1605370193, - "narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=", + "lastModified": 1620759905, + "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", "owner": "numtide", "repo": "flake-utils", - "rev": "5021eac20303a61fafe17224c087f5519baed54d", + "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", "type": "github" }, "original": { @@ -48,11 +32,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1609233094, - "narHash": "sha256-Ltzng3h4LDNjYAvmoX0kQ3023TvdupwuMvm1D7hZkyY=", + "lastModified": 1622230509, + "narHash": "sha256-ybr8ufMIE1OVIG+S7cMihx1HlrJgTV3lLr/oW/LplTM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2b556ea6712cd4fa76a433093df0cb375a267e3d", + "rev": "190d0579fbb13e83756dc2e6df49a3b9221fbfa9", "type": "github" }, "original": { @@ -64,7 +48,6 @@ "root": { "inputs": { "devshell-flake": "devshell-flake", - "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 788ef99..dfedee7 100644 --- a/flake.nix +++ b/flake.nix @@ -5,12 +5,9 @@ flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:NixOS/nixpkgs"; devshell-flake.url = "github:numtide/devshell"; - flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; }; - outputs = { self, nixpkgs, flake-utils, devshell-flake, flake-compat }: - { modules = import ./modules; } - // + outputs = { self, nixpkgs, flake-utils, devshell-flake }: (flake-utils.lib.eachDefaultSystem (system: let @@ -27,29 +24,23 @@ in rec { devShell = with pkgs; devshell.mkShell - { - imports = [ - (devshell.importTOML ./devshell.toml) - ]; - }; + { imports = [ (devshell.importTOML ./devshell.toml) ]; }; packages = flake-utils.lib.flattenTree { inherit (pkgs) - kubenix kubernetes kubectl ; }; - hydraJobs = { - inherit packages; - }; + defaultPackage = pkgs.kubenix; } ) ) // { + modules = import ./src/modules; overlay = final: prev: { - kubenix = prev.callPackage ./kubenix.nix { }; + kubenix = prev.callPackage ./src/kubenix.nix { }; # up to date versions of their nixpkgs equivalents kubernetes = prev.callPackage ./pkgs/applications/networking/cluster/kubernetes { }; diff --git a/lib/compat.nix b/lib/compat.nix index 01f0f02..29e4708 100644 --- a/lib/compat.nix +++ b/lib/compat.nix @@ -1,17 +1,6 @@ -let - inherit (builtins) - fetchTarball - fromJSON - readFile - ; - lockfile = fromJSON (readFile ../flake.lock); -in -input: -let - locked = lockfile.nodes."${input}".locked; - inherit (locked) rev narHash owner repo; -in -fetchTarball { - url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; - sha256 = narHash; +{ + flake-compat = import (builtins.fetchurl { + url = "https://raw.githubusercontent.com/edolstra/flake-compat/99f1c2157fba4bfe6211a321fd0ee43199025dbf/default.nix"; + sha256 = "1vas5z58901gavy5d53n1ima482yvly405jp9l8g07nr4abmzsyb"; + }); } diff --git a/shell.nix b/shell.nix index 9eb132a..fe9feb6 100644 --- a/shell.nix +++ b/shell.nix @@ -1,13 +1,8 @@ -(import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - } - ) - { +{ system ? builtins.currentSystem }: +let +in ( + (import ./lib/compat.nix).flake-compat { src = ./.; - }).shellNix + inherit system; + } +).shellNix diff --git a/tests/default.nix b/tests/default.nix index f210ad0..63cc31c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,6 +1,6 @@ { pkgs ? import { } , lib ? pkgs.lib -, kubenix ? import ../. { inherit pkgs lib; } +, kubenix ? (import ../. { }).default , nixosPath ? toString