diff --git a/.gitignore b/.gitignore index e2486b1..4a99123 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ result -up -hosts/up-* .direnv doc/index.html @@ -8,3 +6,5 @@ doc/index.html vm iso doi + +pkgs/_sources/.shake* diff --git a/doc/SUMMARY.md b/doc/SUMMARY.md index e2b6e9a..4378683 100644 --- a/doc/SUMMARY.md +++ b/doc/SUMMARY.md @@ -31,5 +31,6 @@ - [Integrations](./integrations/index.md) - [Cachix](./integrations/cachix.md) - [Deploy RS](./integrations/deploy.md) + - [NvFetcher](./integrations/nvfetcher.md) - [Hercules CI](./integrations/hercules.md) - [Contributing](./CONTRIBUTING.md) diff --git a/doc/integrations/nvfetcher.md b/doc/integrations/nvfetcher.md new file mode 100644 index 0000000..2bfaa02 --- /dev/null +++ b/doc/integrations/nvfetcher.md @@ -0,0 +1,43 @@ +# nvfetcher +[NvFetcher][nvf] is a workflow companion for updating nix sources. + +You can specify an origin source and an update configuration, and +nvfetcher can for example track updates to a specific branch and +automatically update your nix sources configuration on each run +to the tip of that branch. + +All package source declaration is done in [sources.toml][sources.toml]. + +From within the devshell of this repo, run `nvfetcher`, a wrapped +version of `nvfetcher` that knows where to find and place its files +and commit the results. + +## Usage + +Statically fetching (not tracking) a particular tag from a github repo: +```toml +[manix] +src.manual = "v0.6.3" +fetch.github = "mlvzk/manix" +``` + +Tracking the latest github _release_ from a github repo: +```toml +[manix] +src.github = "mlvzk/manix" # responsible for tracking +fetch.github = "mlvzk/manix" # responsible for fetching +``` + +Tracking the latest commit of a git repository and fetch from a git repo: +```toml +[manix] +src.git = "https://github.com/mlvzk/manix.git" # responsible for tracking +fetch.git = "https://github.com/mlvzk/manix.git" # responsible for fetching +``` + +> ##### _Note:_ +> Please refer to the [NvFetcher Readme][nvf-readme] for more options. + +[nvf: https://github.com/berberman/nvfetcher +[nvf-readme]: https://github.com/berberman/nvfetcher#readme +[sources.toml]: https://github.com/divnix/devos/tree/core/pkgs/sources.toml diff --git a/flake.lock b/flake.lock index bb1c3d6..f16ed90 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1620877075, - "narHash": "sha256-XvgTqtmQZHegu9UMDSR50gK5cHEM2gbnRH0qecmdN54=", + "lastModified": 1626960455, + "narHash": "sha256-N3+qOtsADo59UcG8PxqNMhT94wqTQ73k08gpy1dLaWU=", "owner": "ryantm", "repo": "agenix", - "rev": "e543aa7d68f222e1e771165da9e9a64b5bf7b3e3", + "rev": "fb00f178b3a49a39cc964049075439b575d36d60", "type": "github" }, "original": { @@ -20,6 +20,45 @@ "type": "github" } }, + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "bud": { + "inputs": { + "devshell": [ + "digga", + "devshell" + ], + "nixpkgs": [ + "nixos" + ] + }, + "locked": { + "lastModified": 1626840404, + "narHash": "sha256-6HKRxPlVO4iKyPNAjkjku3JzGX1lgJ+93ieWAx7MY60=", + "owner": "divnix", + "repo": "bud", + "rev": "452ec18574b6e4d8b8a6aae9e190255d4c89768c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "bud", + "type": "github" + } + }, "cachix": { "locked": { "lastModified": 1625876282, @@ -36,34 +75,6 @@ "type": "github" } }, - "ci-agent": { - "inputs": { - "flake-compat": "flake-compat", - "nix-darwin": [ - "darwin" - ], - "nixos-20_09": [ - "nixos" - ], - "nixos-unstable": [ - "latest" - ], - "pre-commit-hooks-nix": "pre-commit-hooks-nix" - }, - "locked": { - "lastModified": 1626066948, - "narHash": "sha256-rBo4nCPyAHb1e/9ysYGH7tW1FV0N2XNvRcJR+g8gugA=", - "owner": "hercules-ci", - "repo": "hercules-ci-agent", - "rev": "7f3265cc42d5f364066c145939ee2812938b991c", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-agent", - "type": "github" - } - }, "darwin": { "inputs": { "nixpkgs": [ @@ -86,17 +97,21 @@ }, "deploy": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "naersk": "naersk", - "nixpkgs": "nixpkgs", - "utils": "utils" + "nixpkgs": [ + "nixpkgs" + ], + "utils": [ + "flake-utils" + ] }, "locked": { - "lastModified": 1616406726, - "narHash": "sha256-n9zmgxR03QNrvs9/fHewqE0j3SjL7Y+cglBCFu3U3rg=", + "lastModified": 1625729093, + "narHash": "sha256-hpo8T7mlVEpHpZIYqhxqt5i/XY8eu4p66MrAg/MCuVY=", "owner": "serokell", "repo": "deploy-rs", - "rev": "9e405fbc5ab5bacbd271fd78c6b6b6877c4d9f8d", + "rev": "587cbcfe8d3ea05c5bb153764d3617012ef28c86", "type": "github" }, "original": { @@ -107,11 +122,11 @@ }, "devshell": { "locked": { - "lastModified": 1622013274, - "narHash": "sha256-mK/Lv0lCbl07dI5s7tR/7nb79HunKnJik3KyR6yeI2k=", + "lastModified": 1625086391, + "narHash": "sha256-IpNPv1v8s4L3CoxhwcgZIitGpcrnNgnj09X7TA0QV3k=", "owner": "numtide", "repo": "devshell", - "rev": "e7faf69e6bf8546517cc936c7f6d31c7eb3abcb2", + "rev": "4b5ac7cf7d9a1cc60b965bb51b59922f2210cbc7", "type": "github" }, "original": { @@ -122,23 +137,32 @@ }, "digga": { "inputs": { + "blank": "blank", "deploy": "deploy", "devshell": "devshell", - "nixlib": "nixlib", - "nixpkgs": "nixpkgs_2", - "utils": "utils_2" + "flake-utils": "flake-utils", + "flake-utils-plus": "flake-utils-plus", + "home-manager": [ + "home" + ], + "nixlib": [ + "nixos" + ], + "nixos-generators": "nixos-generators", + "nixpkgs": [ + "nixos" + ] }, "locked": { - "lastModified": 1623197477, - "narHash": "sha256-2Qk/uIHb1nXre2rRlGonAJmpuamBs7RRfgXhMmS5JkU=", + "lastModified": 1627072303, + "narHash": "sha256-XMrOWqYLLMVcTiTzzgaugUUSqlIRj3/l4JGrs1cvgMU=", "owner": "divnix", "repo": "digga", - "rev": "f69703abc33f221b676966a8435c4f09ef70ff49", + "rev": "cba3f8f76b7fd6816625d9e2e033bfa3462d7125", "type": "github" }, "original": { "owner": "divnix", - "ref": "master", "repo": "digga", "type": "github" } @@ -159,34 +183,39 @@ "type": "github" } }, - "flake-compat_2": { - "flake": false, + "flake-utils": { "locked": { - "lastModified": 1606424373, - "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", "type": "github" }, "original": { - "owner": "edolstra", - "repo": "flake-compat", + "owner": "numtide", + "repo": "flake-utils", "type": "github" } }, - "flake-utils": { + "flake-utils-plus": { + "inputs": { + "flake-utils": [ + "flake-utils" + ] + }, "locked": { - "lastModified": 1620759905, - "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", + "lastModified": 1627071952, + "narHash": "sha256-FhE0KOuI9Kl4eyGJXu4bh9fBP2hbxjnD1DlKHljCcYs=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "51a82925db31073bc4822c9b538a0a3ebf1134b2", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "gytis-ivaskevicius", + "ref": "staging", + "repo": "flake-utils-plus", "type": "github" } }, @@ -212,25 +241,26 @@ ] }, "locked": { - "lastModified": 1626073055, - "narHash": "sha256-vocByfpVu6m9zvtJugDvmd6/9iT2HJuG4tmDICKd0lI=", + "lastModified": 1624228557, + "narHash": "sha256-wwOqe73BsrXfRv1PhyXQFNC8iTET50KvE/HitdkRgxs=", "owner": "nix-community", "repo": "home-manager", - "rev": "775cb20bd4af7781fbf336fb201df02ee3d544bb", + "rev": "35a24648d155843a4d162de98c17b1afd5db51e4", "type": "github" }, "original": { "owner": "nix-community", + "ref": "release-21.05", "repo": "home-manager", "type": "github" } }, "latest": { "locked": { - "lastModified": 1625874246, - "narHash": "sha256-7cGgcysIXz/j/lRpJn7cNJjf0+k7sQ5EuGn62252Svw=", - "path": "/nix/store/7aa32jz0nkywhr9lyrz37w444hra9631-source", - "rev": "45fc7d4a35c5343e58541a7847f6415654ccbb37", + "lastModified": 1626046891, + "narHash": "sha256-Zt8saH+hAehXskW0iFAzk+iMillYoFBxvLReYNqGT9E=", + "path": "/nix/store/hv23pdsi6n7z96pkljv25lfrfh1mnzz7-source", + "rev": "d8f8f31af9d77a48220e4e8a301d1e79774cb7d2", "type": "path" }, "original": { @@ -245,11 +275,11 @@ ] }, "locked": { - "lastModified": 1610392286, - "narHash": "sha256-3wFl5y+4YZO4SgRYK8WE7JIS3p0sxbgrGaQ6RMw+d98=", + "lastModified": 1622810282, + "narHash": "sha256-4wmvM3/xfD0hCdNDIXVzRMfL4yB1J+DjH6Zte2xbAxk=", "owner": "nmattia", "repo": "naersk", - "rev": "d7bfbad3304fd768c0f93a4c3b50976275e6d4be", + "rev": "e8061169e1495871b56be97c5c51d310fae01374", "type": "github" }, "original": { @@ -300,21 +330,6 @@ "type": "github" } }, - "nixlib": { - "locked": { - "lastModified": 1620519687, - "narHash": "sha256-+6Dd72b2CASuXm2W7KRxZIE7AOy/dj4mU28vaF+zxcs=", - "owner": "divnix", - "repo": "nixpkgs.lib", - "rev": "c7b6169809c5f74dd0c34f3d69e9d12ba4d448de", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "nixos": { "locked": { "lastModified": 1626852498, @@ -330,6 +345,29 @@ "type": "indirect" } }, + "nixos-generators": { + "inputs": { + "nixlib": [ + "nixlib" + ], + "nixpkgs": [ + "blank" + ] + }, + "locked": { + "lastModified": 1624973746, + "narHash": "sha256-11JbJRduNwyf556gndGErR5/12ceyHOHBfEuha5Vws4=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "022ef440af8dc237ab1f59fa363cb1e25783ec3e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixos-hardware": { "locked": { "lastModified": 1625333638, @@ -360,22 +398,6 @@ "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 1610942247, - "narHash": "sha256-PKo1ATAlC6BmfYSRmX0TVmNoFbrec+A5OKcabGEu2yU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "7d71001b796340b219d1bfa8552c81995017544a", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgsWayland": { "inputs": { "cachix": "cachix", @@ -384,11 +406,11 @@ ] }, "locked": { - "lastModified": 1626290283, - "narHash": "sha256-2RjWMFA9fYdLkyvBj2oUUUygZm461kW4r3cB4Txo+xA=", + "lastModified": 1626505081, + "narHash": "sha256-dcKU/hs4EIJIJu5nNqtX169nw+eHT6lIrNmOvg/Io4s=", "owner": "colemickens", "repo": "nixpkgs-wayland", - "rev": "09d4d9c873d48a13f15b7d950948131a4bdb3028", + "rev": "fd3be17ace1aa22ed6b1d0bd01a979deb098cbbd", "type": "github" }, "original": { @@ -397,21 +419,6 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1620962350, - "narHash": "sha256-9ASW4d4/Z8HmRvuJI8rxbEOTbXTBpQ8y+CmFYBwtXzE=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "5d4a430472cafada97888cc80672fab255231f57", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "type": "github" - } - }, "nur": { "locked": { "lastModified": 1622199699, @@ -425,48 +432,66 @@ "type": "indirect" } }, - "pkgs": { + "nvfetcher": { "inputs": { + "flake-compat": [ + "digga", + "deploy", + "flake-compat" + ], + "flake-utils": [ + "digga", + "flake-utils-plus", + "flake-utils" + ], "nixpkgs": [ - "nixos" + "latest" ] }, "locked": { - "narHash": "sha256-Zs7dc0dNNa0Z3//+Gckxj7SKrMqVovY0xZZ1z8xWnEg=", - "path": "./pkgs", - "type": "path" - }, - "original": { - "path": "./pkgs", - "type": "path" - } - }, - "pre-commit-hooks-nix": { - "flake": false, - "locked": { - "lastModified": 1622650193, - "narHash": "sha256-qSzUpJDv04ajS9FXoCq6NjVF3qOt9IiGIiGh0P8amyw=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "0398f0649e0a741660ac5e8216760bae5cc78579", + "lastModified": 1627126476, + "narHash": "sha256-WvUITmKad4aqtSgICVgwpasrCcAd5yrdCF+27Hz4+bw=", + "owner": "berberman", + "repo": "nvfetcher", + "rev": "5a44a2b0675108d1abd0c8c820b20593b65c9512", "type": "github" }, "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", + "owner": "berberman", + "repo": "nvfetcher", "type": "github" } }, "root": { "inputs": { "agenix": "agenix", - "ci-agent": "ci-agent", + "blank": [ + "digga", + "blank" + ], + "bud": "bud", "darwin": "darwin", + "deploy": [ + "digga", + "deploy" + ], "digga": "digga", + "flake-utils": [ + "digga", + "flake-utils" + ], + "flake-utils-plus": [ + "digga", + "flake-utils-plus" + ], "home": "home", "latest": "latest", "naersk": "naersk_2", "nixEvalLsp": "nixEvalLsp", + "nixlib": [ + "digga", + "nixlib" + ], "nixos": "nixos", "nixos-hardware": "nixos-hardware", "nixosPersistence": "nixosPersistence", @@ -475,41 +500,7 @@ ], "nixpkgsWayland": "nixpkgsWayland", "nur": "nur", - "pkgs": "pkgs" - } - }, - "utils": { - "locked": { - "lastModified": 1610051610, - "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "utils_2": { - "inputs": { - "flake-utils": "flake-utils" - }, - "locked": { - "lastModified": 1622583383, - "narHash": "sha256-2DFx619SNfjzYwqx1ryae8zHnTh+N7VsZkbtAbrYIIA=", - "owner": "gytis-ivaskevicius", - "repo": "flake-utils-plus", - "rev": "6b2ea4b02cad77fac581c6a9ec4f822ba87dce5c", - "type": "github" - }, - "original": { - "owner": "gytis-ivaskevicius", - "ref": "staging", - "repo": "flake-utils-plus", - "type": "github" + "nvfetcher": "nvfetcher" } } }, diff --git a/flake.nix b/flake.nix index 3afc626..46130d3 100644 --- a/flake.nix +++ b/flake.nix @@ -1,29 +1,45 @@ { description = "A highly structured configuration database."; + nixConfig.extra-experimental-features = "nix-command flakes ca-references"; + nixConfig.extra-substituters = "https://nrdxp.cachix.org https://nix-community.cachix.org"; + nixConfig.extra-trusted-public-keys = "nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="; + inputs = { nixos.url = "nixpkgs/nixos-unstable"; - nixpkgs.follows = "nixos"; latest.url = "nixpkgs"; - digga.url = "github:divnix/digga/master"; - ci-agent = { - url = "github:hercules-ci/hercules-ci-agent"; - inputs = { nix-darwin.follows = "darwin"; nixos-20_09.follows = "nixos"; nixos-unstable.follows = "latest"; }; - }; + digga.url = "github:divnix/digga"; + digga.inputs.nixpkgs.follows = "nixos"; + digga.inputs.nixlib.follows = "nixos"; + digga.inputs.home-manager.follows = "home"; + + bud.url = "github:divnix/bud"; + bud.inputs.nixpkgs.follows = "nixos"; + bud.inputs.devshell.follows = "digga/devshell"; + + home.url = "github:nix-community/home-manager/release-21.05"; + home.inputs.nixpkgs.follows = "nixos"; + darwin.url = "github:LnL7/nix-darwin"; darwin.inputs.nixpkgs.follows = "latest"; - home.url = "github:nix-community/home-manager"; - home.inputs.nixpkgs.follows = "nixos"; - naersk.url = "github:nmattia/naersk"; - naersk.inputs.nixpkgs.follows = "latest"; + + deploy.follows = "digga/deploy"; + agenix.url = "github:ryantm/agenix"; agenix.inputs.nixpkgs.follows = "latest"; + + nvfetcher.url = "github:berberman/nvfetcher"; + nvfetcher.inputs.nixpkgs.follows = "latest"; + nvfetcher.inputs.flake-compat.follows = "digga/deploy/flake-compat"; + nvfetcher.inputs.flake-utils.follows = "digga/flake-utils-plus/flake-utils"; + + naersk.url = "github:nmattia/naersk"; + naersk.inputs.nixpkgs.follows = "latest"; + nixos-hardware.url = "github:nixos/nixos-hardware"; - pkgs.url = "path:./pkgs"; - pkgs.inputs.nixpkgs.follows = "nixos"; nixosPersistence.url = "github:nix-community/impermanence"; nixEvalLsp = { url = "github:aaronjanse/nix-eval-lsp"; @@ -33,14 +49,21 @@ url = "github:colemickens/nixpkgs-wayland"; inputs.nixpkgs.follows = "nixos"; }; + # start ANTI CORRUPTION LAYER + # remove after https://github.com/NixOS/nix/pull/4641 + nixpkgs.follows = "nixos"; + nixlib.follows = "digga/nixlib"; + blank.follows = "digga/blank"; + flake-utils-plus.follows = "digga/flake-utils-plus"; + flake-utils.follows = "digga/flake-utils"; + # end ANTI CORRUPTION LAYER }; outputs = { self - , pkgs , digga + , bud , nixos - , ci-agent , home , nixos-hardware , nur @@ -48,93 +71,99 @@ , nixosPersistence , nixpkgsWayland , nixEvalLsp + , nvfetcher + , deploy , ... } @ inputs: - digga.lib.mkFlake { - inherit self inputs; + digga.lib.mkFlake + { + inherit self inputs; - lib = import ./lib { lib = digga.lib // nixos.lib; }; + channelsConfig = { allowUnfree = true; }; - channelsConfig = { - allowUnfree = true; - }; + channels = { + nixos = { + imports = [ (digga.lib.importOverlays ./overlays) ]; + overlays = [ + digga.overlays.patchedNix + nur.overlay + agenix.overlay + nvfetcher.overlay + deploy.overlay + ./pkgs/default.nix + ]; + }; + latest = { }; + }; + + lib = import ./lib { lib = digga.lib // nixos.lib; }; + + sharedOverlays = [ + (final: prev: { + __dontExport = true; + lib = prev.lib.extend (lfinal: lprev: { + our = self.lib; + }); + }) + ]; - channels = { nixos = { - imports = [ (digga.lib.importers.overlays ./overlays) ]; - overlays = [ - ./pkgs/default.nix - pkgs.overlay # for `srcs` - nur.overlay - nixpkgsWayland.overlay - (final: prev: { - inherit (nixEvalLsp.packages.${prev.system}) nix-eval-lsp; - }) - agenix.overlay - ]; - }; - latest = { }; - }; + hostDefaults = { + system = "x86_64-linux"; + channelName = "nixos"; + imports = [ (digga.lib.importModules ./modules) ]; + externalModules = [ + { lib.our = self.lib; } + digga.nixosModules.bootstrapIso + digga.nixosModules.nixConfig + home.nixosModules.home-manager + agenix.nixosModules.age + bud.nixosModules.bud + nixosPersistence.nixosModules.impermanence + ]; + }; - sharedOverlays = [ - (final: prev: { - lib = prev.lib.extend (lfinal: lprev: { - our = self.lib; - }); - }) - ]; - - nixos = { - hostDefaults = { - system = "x86_64-linux"; - channelName = "nixos"; - modules = ./modules/module-list.nix; - externalModules = [ - { _module.args.ourLib = self.lib; } - ci-agent.nixosModules.agent-profile - home.nixosModules.home-manager - nixosPersistence.nixosModules.impermanence - agenix.nixosModules.age - ./modules/customBuilds.nix - ]; - }; - - imports = [ (digga.lib.importers.hosts ./hosts) ]; - hosts = { - /* set host specific properties here */ - NixOS = { }; - }; - importables = rec { - profiles = (digga.lib.importers.rakeLeaves ./profiles) // { users = digga.lib.importers.rakeLeaves ./users; }; - suites = with profiles; { - base = [ cachix core users.root ]; - work = [ users.patriot develop ]; + imports = [ (digga.lib.importHosts ./hosts) ]; + hosts = { + /* set host specific properties here */ + NixOS = { }; + }; + importables = rec { + profiles = digga.lib.rakeLeaves ./profiles // { + users = digga.lib.rakeLeaves ./users; + }; + suites = with profiles; { + base = [ cachix core users.root ]; + work = [ users.patriot develop ]; + }; }; }; - }; - home = { - modules = ./users/modules/module-list.nix; - externalModules = [ ]; - importables = rec { - profiles = digga.lib.importers.rakeLeaves ./users/profiles; - suites = with profiles; { - base = [ direnv git starship ]; + home = { + imports = [ (digga.lib.importModules ./users/modules) ]; + externalModules = [ ]; + importables = rec { + profiles = digga.lib.rakeLeaves ./users/profiles; + suites = with profiles; rec { + base = [ direnv git starship ]; + }; }; }; - }; - devshell.externalModules = { pkgs, ... }: { - packages = [ pkgs.agenix ]; - }; + devshell = ./shell; - homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; + homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; - deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; + deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; - defaultTemplate = self.templates.flk; - templates.flk.path = ./.; - templates.flk.description = "flk template"; + defaultTemplate = self.templates.bud; + templates.bud.path = ./.; + templates.bud.description = "bud template"; + + } + // + { + budModules = { devos = import ./pkgs/bud; }; } ; } diff --git a/modules/customBuilds.nix b/modules/customBuilds.nix deleted file mode 100644 index 7181f65..0000000 --- a/modules/customBuilds.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ lib, self, diggaLib, config, modules, channel, ... }: -let - mkBuild = buildModule: - # TODO: get specialArgs as a module argument and drop builderArgs usage - channel.input.lib.nixosSystem (diggaLib.mergeAny config.lib.builderArgs { - modules = [ buildModule ]; - }); -in -{ - system.build = { - iso = (mkBuild (diggaLib.modules.isoConfig { - inherit self; - fullHostConfig = config; - })).config.system.build.isoImage; - - homes = (mkBuild ({ config, ... }: { - home-manager.useUserPackages = lib.mkForce false; - home-manager.sharedModules = [ - { - home.sessionVariables = { - inherit (config.environment.sessionVariables) NIX_PATH; - }; - xdg.configFile."nix/registry.json".text = - config.environment.etc."nix/registry.json".text; - } - ]; - })).config.home-manager.users; - - digitalOcean = (mkBuild ({ modulesPath, ... }: { - imports = [ "${modulesPath}/virtualisation/digital-ocean-image.nix" ]; - })).config.system.build.digitalOceanImage; - }; -} diff --git a/modules/hm-system-defaults.nix b/modules/hm-system-defaults.nix new file mode 100644 index 0000000..7b442a6 --- /dev/null +++ b/modules/hm-system-defaults.nix @@ -0,0 +1,11 @@ +{ config, ... }: { + home-manager.sharedModules = [ + { + home.sessionVariables = { + inherit (config.environment.sessionVariables) NIX_PATH; + }; + xdg.configFile."nix/registry.json".text = + config.environment.etc."nix/registry.json".text; + } + ]; +} diff --git a/modules/nix-path.nix b/modules/nix-path.nix new file mode 100644 index 0000000..273f67a --- /dev/null +++ b/modules/nix-path.nix @@ -0,0 +1,7 @@ +{ channel, inputs, ... }: { + nix.nixPath = [ + "nixpkgs=${channel.input}" + "nixos-config=${../lib/compat/nixos}" + "home-manager=${inputs.home}" + ]; +} diff --git a/overlays/manix.nix b/overlays/manix.nix new file mode 100644 index 0000000..d39baa7 --- /dev/null +++ b/overlays/manix.nix @@ -0,0 +1,5 @@ +final: prev: { + manix = prev.manix.overrideAttrs (o: rec{ + inherit (prev.sources.manix) pname version src; + }); +} diff --git a/overlays/overrides.nix b/overlays/overrides.nix index face31f..c50056c 100644 --- a/overlays/overrides.nix +++ b/overlays/overrides.nix @@ -6,13 +6,13 @@ channels: final: prev: { dhall discord element-desktop - manix rage nixpkgs-fmt qutebrowser signal-desktop starship; +<<<<<<< HEAD haskellPackages = prev.haskellPackages.override { overrides = hfinal: hprev: let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version; @@ -23,4 +23,18 @@ channels: final: prev: { haskell-language-server; }; }; +======= + + haskellPackages = prev.haskellPackages.override + (old: { + overrides = prev.lib.composeExtensions (old.overrides or (_: _: { })) (hfinal: hprev: + let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version; + in + { + # same for haskell packages, matching ghc versions + inherit (channels.latest.haskell.packages."ghc${version}") + haskell-language-server; + }); + }); +>>>>>>> upstream/develop } diff --git a/overlays/various-flake-fixes.nix b/overlays/various-flake-fixes.nix new file mode 100644 index 0000000..7dbfc18 --- /dev/null +++ b/overlays/various-flake-fixes.nix @@ -0,0 +1,11 @@ +final: prev: { + # Since: https://github.com/NixOS/nixpkgs/pull/126137 + nix-direnv = + if builtins.hasAttr "enableFlakes" prev.nix-direnv.override.__functionArgs + then + prev.nix-direnv.override + { + enableFlakes = true; + } + else prev.nix-direnv; +} diff --git a/pkgs/_sources/generated.nix b/pkgs/_sources/generated.nix new file mode 100644 index 0000000..0d13ac0 --- /dev/null +++ b/pkgs/_sources/generated.nix @@ -0,0 +1,17 @@ +# This file was generated by nvfetcher, please do not modify it manually. +{ fetchgit, fetchurl }: +{ + manix = { + pname = "manix"; + version = "d08e7ca185445b929f097f8bfb1243a8ef3e10e4"; + src = fetchgit { + url = "https://github.com/mlvzk/manix"; + rev = "d08e7ca185445b929f097f8bfb1243a8ef3e10e4"; + fetchSubmodules = false; + deepClone = false; + leaveDotGit = false; + sha256 = "1b7xi8c2drbwzfz70czddc4j33s7g1alirv12dwl91hbqxifx8qs"; + }; + + }; +} diff --git a/pkgs/bud/default.nix b/pkgs/bud/default.nix new file mode 100644 index 0000000..c486636 --- /dev/null +++ b/pkgs/bud/default.nix @@ -0,0 +1,10 @@ +{ pkgs, lib, budUtils, ... }: { + bud.cmds = with pkgs; { + get = { + writer = budUtils.writeBashWithPaths [ nixUnstable git coreutils ]; + synopsis = "get [DEST]"; + help = "Copy the desired template to DEST"; + script = ./get.bash; + }; + }; +} diff --git a/pkgs/bud/get.bash b/pkgs/bud/get.bash new file mode 100644 index 0000000..3b4d9a7 --- /dev/null +++ b/pkgs/bud/get.bash @@ -0,0 +1 @@ +nix flake new -t "github:divnix/devos/core" "${2:-devos}" diff --git a/pkgs/default.nix b/pkgs/default.nix index ce16870..924a230 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1 +1,5 @@ -final: prev: { } +final: prev: { + # keep sources this first + sources = prev.callPackage (import ./_sources/generated.nix) { }; + # then, call packages with `final.callPackage` +} diff --git a/pkgs/flake.lock b/pkgs/flake.lock deleted file mode 100644 index ef3f5a9..0000000 --- a/pkgs/flake.lock +++ /dev/null @@ -1,25 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1615926763, - "narHash": "sha256-yeq8A3EPNuQVlsxlEQrIRsklfJwJK0Us6jtcG/u8wNs=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b702a56d417647de4090ac56c0f18bdc7e646610", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/pkgs/flake.nix b/pkgs/flake.nix deleted file mode 100644 index 1b6cc0a..0000000 --- a/pkgs/flake.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ - description = "Package Sources"; - - inputs = { }; - - outputs = { self, nixpkgs, ... }: { - overlay = final: prev: { - inherit (self) srcs; - }; - - srcs = - let - inherit (nixpkgs) lib; - - mkVersion = name: input: - let - inputs = (builtins.fromJSON - (builtins.readFile ./flake.lock)).nodes; - - ref = - if lib.hasAttrByPath [ name "original" "ref" ] inputs - then inputs.${name}.original.ref - else ""; - - version = - let version' = builtins.match - "[[:alpha:]]*[-._]?([0-9]+(\.[0-9]+)*)+" - ref; - in - if lib.isList version' - then lib.head version' - else if input ? lastModifiedDate && input ? shortRev - then "${lib.substring 0 8 input.lastModifiedDate}_${input.shortRev}" - else null; - in - version; - in - lib.mapAttrs - (pname: input: - let - version = mkVersion pname input; - in - input // { inherit pname; } - // lib.optionalAttrs (! isNull version) - { - inherit version; - } - ) - (lib.filterAttrs (n: _: n != "nixpkgs") - self.inputs); - }; -} diff --git a/pkgs/sources.toml b/pkgs/sources.toml new file mode 100644 index 0000000..f7af168 --- /dev/null +++ b/pkgs/sources.toml @@ -0,0 +1,4 @@ +# nvfetcher.toml +[manix] +src.git = "https://github.com/mlvzk/manix" +fetch.github = "mlvzk/manix" diff --git a/profiles/core/default.nix b/profiles/core/default.nix index 260a918..49c0e53 100644 --- a/profiles/core/default.nix +++ b/profiles/core/default.nix @@ -26,7 +26,7 @@ in dosfstools fd git - gotop + bottom gptfdisk iputils jq diff --git a/shell/default.nix b/shell/default.nix new file mode 100644 index 0000000..aef90a5 --- /dev/null +++ b/shell/default.nix @@ -0,0 +1,10 @@ +{ self, inputs, ... }: +{ + externalModules = with inputs; [ + bud.devshellModules.bud + ]; + modules = [ + ./devos.nix + ]; +} + diff --git a/shell/devos.nix b/shell/devos.nix new file mode 100644 index 0000000..83101d2 --- /dev/null +++ b/shell/devos.nix @@ -0,0 +1,61 @@ +{ pkgs, extraModulesPath, ... }: +let + + hooks = import ./hooks; + + pkgWithCategory = category: package: { inherit package category; }; + linter = pkgWithCategory "linter"; + docs = pkgWithCategory "docs"; + devos = pkgWithCategory "devos"; + +in +{ + _file = toString ./.; + + imports = [ "${extraModulesPath}/git/hooks.nix" ]; + git = { inherit hooks; }; + + # tempfix: remove when merged https://github.com/numtide/devshell/pull/123 + devshell.startup.load_profiles = pkgs.lib.mkForce (pkgs.lib.noDepEntry '' + # PATH is devshell's exorbitant privilige: + # fence against its pollution + _PATH=''${PATH} + # Load installed profiles + for file in "$DEVSHELL_DIR/etc/profile.d/"*.sh; do + # If that folder doesn't exist, bash loves to return the whole glob + [[ -f "$file" ]] && source "$file" + done + # Exert exorbitant privilige and leave no trace + export PATH=''${_PATH} + unset _PATH + ''); + + packages = with pkgs; [ + git-crypt + ]; + + commands = with pkgs; [ + (devos nixUnstable) + (devos agenix) + { + category = "devos"; + name = pkgs.nvfetcher-bin.pname; + help = pkgs.nvfetcher-bin.meta.description; + command = "cd $DEVSHELL_ROOT/pkgs; ${pkgs.nvfetcher-bin}/bin/nvfetcher -c ./sources.toml --no-output $@; nixpkgs-fmt _sources/"; + } + (linter nixpkgs-fmt) + (linter editorconfig-checker) + # (docs python3Packages.grip) too many deps + (docs mdbook) + ] + + ++ lib.optional + (pkgs ? deploy-rs) + (devos deploy-rs.deploy-rs) + + ++ lib.optional + (system != "i686-linux") + (devos cachix) + + ; +} diff --git a/shell/hooks/default.nix b/shell/hooks/default.nix new file mode 100644 index 0000000..10f2c9d --- /dev/null +++ b/shell/hooks/default.nix @@ -0,0 +1,4 @@ +{ + enable = true; + pre-commit.text = builtins.readFile ./pre-commit.sh; +} diff --git a/shell/hooks/pre-commit.sh b/shell/hooks/pre-commit.sh new file mode 100755 index 0000000..985d3b4 --- /dev/null +++ b/shell/hooks/pre-commit.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(${git}/bin/git hash-object -t tree /dev/null) +fi + +diff="git diff-index --name-only --cached $against --diff-filter d" + +nix_files=($($diff -- '*.nix')) +all_files=($($diff)) + +# Format staged nix files. +if [[ -n "${nix_files[@]}" ]]; then + nixpkgs-fmt "${nix_files[@]}" \ + && git add "${nix_files[@]}" +fi + +# check editorconfig +editorconfig-checker -- "${all_files[@]}" +if [[ $? != '0' ]]; then + printf "%b\n" \ + "\nCode is not aligned with .editorconfig" \ + "Review the output and commit your fixes" >&2 + exit 1 +fi diff --git a/users/modules/.flake-keep b/users/modules/.flake-keep new file mode 100644 index 0000000..e69de29 diff --git a/users/modules/module-list.nix b/users/modules/module-list.nix deleted file mode 100644 index 1e3ec72..0000000 --- a/users/modules/module-list.nix +++ /dev/null @@ -1 +0,0 @@ -[ ] diff --git a/users/nixos/default.nix b/users/nixos/default.nix index 700467b..5c037fe 100644 --- a/users/nixos/default.nix +++ b/users/nixos/default.nix @@ -1,8 +1,6 @@ -{ ... }: +{ hmUsers, ... }: { - home-manager.users.nixos = { suites, ... }: { - imports = suites.base; - }; + home-manager.users = { inherit (hmUsers) nixos; }; users.users.nixos = { uid = 1000;