From d0470d5aafa7a5778b629bcd1deb51b4be136ea7 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Mon, 27 Mar 2023 13:35:59 +0200 Subject: [PATCH] flake: pull in changes from digga upstream See: https://github.com/divnix/digga/compare/54ede8e591d288c176a09d6fcf4b123896c0bf0f...0595ae70cdb5ccf1ab031199fe98551c4b378bd9?diff=unified --- default.nix | 1 - doc/api-reference.md | 2 +- doc/book.toml | 6 +++++- doc/concepts/users.md | 17 ++--------------- doc/start/index.md | 32 +++++++++++--------------------- doc/tests.md | 15 ++++++++++++--- lib/default.nix | 10 +++++++++- modules/core/nix.nix | 6 +++--- shell/devos.nix | 31 +++++++++++++------------------ shell/hooks/default.nix | 6 ++++-- 10 files changed, 60 insertions(+), 66 deletions(-) diff --git a/default.nix b/default.nix index 0468b228..3d5b5f96 100644 --- a/default.nix +++ b/default.nix @@ -5,7 +5,6 @@ let ciSystems = [ "aarch64-linux" - "i686-linux" "x86_64-linux" ]; diff --git a/doc/api-reference.md b/doc/api-reference.md index ee2cb9e7..41fa2f78 100755 --- a/doc/api-reference.md +++ b/doc/api-reference.md @@ -59,5 +59,5 @@ list of strings _*Default*_ ``` -["aarch64-linux","aarch64-darwin","i686-linux","x86_64-darwin","x86_64-linux"] +["aarch64-linux","aarch64-darwin","x86_64-darwin","x86_64-linux"] ``` diff --git a/doc/book.toml b/doc/book.toml index f9dca6a3..beb67004 100644 --- a/doc/book.toml +++ b/doc/book.toml @@ -1,5 +1,9 @@ [book] -authors = ["Timothy DeHerrera"] +authors = [ + "Timothy DeHerrera", + "Parthiv Seetharaman", + "David Arnold", +] language = "en" multilingual = false src = "." diff --git a/doc/concepts/users.md b/doc/concepts/users.md index 3cb4480e..85e2f070 100644 --- a/doc/concepts/users.md +++ b/doc/concepts/users.md @@ -9,8 +9,7 @@ Users are a special case of [profiles](profiles.md) that define system users and [home-manager][home-manager] configurations. For your convenience, home manager is wired in by default so all you have to worry about is declaring -your users. For a fully fleshed out example, check out the developers personal -[branch](https://github.com/divnix/devos/tree/nrd/users/nrd/default.nix). +your users. ## Basic Usage @@ -60,18 +59,6 @@ using the `homeConfigurations` flake output. This is great for keeping your environment consistent across Unix-like systems, including macOS. -### From within the projects devshell: - -```sh -# builds the pub-solar user defined in the PubSolarOS host -nix build '.#homeConfigurations."pub-solar@PubSolarOS".activationPackage' - -# build and activate -nix build '.#homeConfigurations."pub-solar@PubSolarOS".activationPackage' && ./result/activate && unlink result -``` - -### Manually from outside the project: - ```sh # build nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPackage" @@ -81,5 +68,5 @@ nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPac ``` [home-manager]: https://nix-community.github.io/home-manager -[modules-list]: https://github.com/divnix/devos/tree/main/users/modules/module-list.nix +[modules-list]: https://github.com/divnix/digga/tree/main/users/modules/module-list.nix [portableuser]: https://digga.divnix.com/api-reference-home.html#homeusers diff --git a/doc/start/index.md b/doc/start/index.md index 06e41292..c160df9f 100644 --- a/doc/start/index.md +++ b/doc/start/index.md @@ -4,7 +4,8 @@ The only dependency is nix, so make sure you have it [installed][install-nix]. ## Get the Template -If you currently don't have flakes setup, you can utilize the digga shell to pull the template: +If you currently don't have flakes setup, you can utilize the digga shell to +pull the template: ```sh nix-shell "https://github.com/divnix/digga/archive/main.tar.gz" \ @@ -22,37 +23,26 @@ Then make sure to create the git repository: ```sh git init git add . -git commit -m init +git commit ``` -To drop into a nix-shell, if you don't have flakes setup, use the digga shell to create a `flake.lock`: - -```sh -nix-shell "https://github.com/divnix/digga/archive/main.tar.gz" \ - --run "nix flake lock" -``` - -Or if you do have flakes support, just run: - -```sh -nix flake lock -``` - -Finally, run `nix-shell` to get to an interactive shell with all the dependencies, including the unstable nix -version required. You can run `menu` to confirm that you are using digga (expected output includes [docs], [general commands], [linter], etc.). +Finally, run `nix-shell` to get to an interactive shell with all the +dependencies, including the unstable nix version required. You can run `menu` to +confirm that you are using digga (expected output includes [docs], [general +commands], [linter], etc.). In addition, the [binary cache](../integrations/cachix.md) is added for faster deployment. -> ##### _Notes:_ +> # _Notes:_ > > - Flakes ignore files that have not been added to git, so be sure to stage new > files before building the system. > - You can choose to simply clone the repo with git if you want to follow > upstream changes. -> - If the `nix-shell -p cachix --run "cachix use nrdxp"` line doesn't work -> you can try with sudo: `sudo nix-shell -p cachix --run "cachix use nrdxp"` +> - If the `nix-shell -p cachix --run "cachix use nrdxp"` line doesn't work you +> can try with sudo: `sudo nix-shell -p cachix --run "cachix use nrdxp"` -## Next Steps: +## Next Steps - [Make installable ISO](./iso.md) diff --git a/doc/tests.md b/doc/tests.md index aa2bda14..24dead09 100644 --- a/doc/tests.md +++ b/doc/tests.md @@ -14,12 +14,21 @@ be built during CI. ## Integration Tests -All your profiles defined in suites will be tested in a NixOS VM. +All your profiles defined in suites can be tested against an individual host. +Simply use digga's pre-baked `digga.lib.allProfilesTest` like so: + +```nix +{ + hosts = { + Morty.tests = [ allProfilesTest ]; + }; +} +``` You can write integration tests for one or more NixOS VMs that can, optionally, be networked together, and yes, it's as awesome as it sounds! -Be sure to use the `mkTest` function from digga, `digga.lib.pkgs-lib.mkTest` +Be sure to use the `mkTest` function from Digga, `digga.lib.mkTest` which wraps the official [testing-python][testing-python] function to ensure that the system is setup exactly as it is for a bare DevOS system. There are already great resources for learning how to use these tests effectively, @@ -28,7 +37,7 @@ and the examples in [nixpkgs][nixos-tests]. [test-doc]: https://nixos.org/manual/nixos/stable/index.html#sec-nixos-tests [test-blog]: https://www.haskellforall.com/2020/11/how-to-use-nixos-for-lightweight.html -[default]: https://github.com/divnix/devos/tree/main/tests/default.nix +[default]: https://github.com/divnix/devos/tree/core/tests/default.nix [run-test]: https://github.com/NixOS/nixpkgs/blob/6571462647d7316aff8b8597ecdf5922547bf365/lib/debug.nix#L154-L166 [nixos-tests]: https://github.com/NixOS/nixpkgs/tree/master/nixos/tests [testing-python]: https://github.com/NixOS/nixpkgs/tree/master/nixos/lib/testing-python.nix diff --git a/lib/default.nix b/lib/default.nix index 9bc86f1a..ac167511 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,2 +1,10 @@ {lib}: -lib.makeExtensible (self: {}) +lib.makeExtensible (self: let + callLibs = file: import file {lib = self;}; +in rec { + ## Define your own library functions here! + #id = x: x; + ## Or in files, containing functions that take {lib} + #foo = callLibs ./foo.nix; + ## In configs, they can be used under "lib.our" +}) diff --git a/modules/core/nix.nix b/modules/core/nix.nix index 711304ba..6df8803a 100644 --- a/modules/core/nix.nix +++ b/modules/core/nix.nix @@ -15,10 +15,10 @@ auto-optimise-store = true; # Prevents impurities in builds sandbox = true; - # give root and @wheel special privileges with nix + # Give root and @wheel special privileges with nix trusted-users = ["root" "@wheel"]; - # This is just a representation of the nix default - system-features = ["nixos-test" "benchmark" "big-parallel" "kvm"]; + # Allow only group wheel to connect to the nix daemon + allowed-users = ["@wheel"]; }; # Generally useful nix option defaults extraOptions = '' diff --git a/shell/devos.nix b/shell/devos.nix index c216f3b9..fdbcee2e 100644 --- a/shell/devos.nix +++ b/shell/devos.nix @@ -8,11 +8,11 @@ inherit (pkgs) agenix + alejandra cachix editorconfig-checker - mdbook nix - alejandra + nodePackages nvfetcher shellcheck shfmt @@ -25,21 +25,23 @@ prettier ; - hooks = import ./hooks; - pkgWithCategory = category: package: {inherit package category;}; devos = pkgWithCategory "devos"; - linter = pkgWithCategory "linter"; - docs = pkgWithCategory "docs"; + formatter = pkgWithCategory "linter"; in { - _file = toString ./.; - - imports = ["${extraModulesPath}/git/hooks.nix"]; - git = {inherit hooks;}; + imports = ["${extraModulesPath}/git/hooks.nix" ./hooks]; # override for our own welcome devshell.name = pkgs.lib.mkForce "PubSolarOS"; + packages = [ + alejandra + editorconfig-checker + nodePackages.prettier + shellcheck + shfmt + ]; + commands = with pkgs; [ (devos nix) @@ -50,14 +52,7 @@ in { help = pkgs.nvfetcher.meta.description; command = "cd $PRJ_ROOT/pkgs; ${pkgs.nvfetcher}/bin/nvfetcher -c ./sources.toml $@"; } - (linter alejandra) - (linter editorconfig-checker) - (linter nodePackages.prettier) - (linter shfmt) - (linter shellcheck) - (linter treefmt) - - (docs mdbook) + (formatter treefmt) ] ++ lib.optionals (!pkgs.stdenv.buildPlatform.isi686) [ (devos cachix) diff --git a/shell/hooks/default.nix b/shell/hooks/default.nix index 10f2c9d2..1d60d49c 100644 --- a/shell/hooks/default.nix +++ b/shell/hooks/default.nix @@ -1,4 +1,6 @@ { - enable = true; - pre-commit.text = builtins.readFile ./pre-commit.sh; + git.hooks = { + enable = true; + pre-commit.text = builtins.readFile ./pre-commit.sh; + }; }