diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e4fc197..c8a8f64 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -2,7 +2,7 @@ name: "Check & Cachix" on: push: branches: - - core + - main - trying - staging jobs: diff --git a/.github/workflows/mdbook_docs.yml b/.github/workflows/mdbook_docs.yml index 842171c..5faf9c2 100644 --- a/.github/workflows/mdbook_docs.yml +++ b/.github/workflows/mdbook_docs.yml @@ -3,7 +3,7 @@ name: Deploy Docs to GitHub Pages on: push: branches: - - core + - main jobs: deploy: 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/README.md b/README.md index b7cd887..f088ca0 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ following giants][giants]: ### :family: — like family - [`numtide/devshell`][devshell] - [`serokell/deploy-rs`][deploy] +- [`berberman/nvfetcher`][nvfetcher] - [`NixOS/nixpkgs`][nixpkgs] :heart: @@ -68,23 +69,23 @@ goals are sufficiently upstreamed into "the Nix", dissolved. # License DevOS is licensed under the [MIT License][mit]. -[mk-flake]: https://github.com/divnix/digga/tree/master/src/mkFlake -[nixpkgs]: https://github.com/NixOS/nixpkgs -[deploy]: https://github.com/serokell/deploy-rs -[toc]: https://github.com/divnix/devos/blob/core/flake.nix -[giants]: https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants -[digga]: https://github.com/divnix/digga -[fup]: https://github.com/gytis-ivaskevicius/flake-utils-plus -[fu]: https://github.com/numtide/flake-utils -[devshell]: https://github.com/numtide/devshell -[nix]: https://nixos.org/manual/nix/stable -[mit]: https://mit-license.org -[nixos]: https://nixos.org/manual/nixos/stable -[home-manager]: https://nix-community.github.io/home-manager -[flakes]: https://nixos.wiki/wiki/Flakes -[flake-doc]: https://github.com/NixOS/nix/blob/master/src/nix/flake.md -[core]: https://github.com/divnix/devos [community]: https://github.com/divnix/devos/tree/community +[core]: https://github.com/divnix/devos +[deploy]: https://github.com/serokell/deploy-rs +[devshell]: https://github.com/numtide/devshell +[digga]: https://github.com/divnix/digga [dotfiles]: https://github.com/hlissner/dotfiles +[flake-doc]: https://github.com/NixOS/nix/blob/master/src/nix/flake.md +[flakes]: https://nixos.wiki/wiki/Flakes +[fu]: https://github.com/numtide/flake-utils +[fup]: https://github.com/gytis-ivaskevicius/flake-utils-plus +[giants]: https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants +[home-manager]: https://nix-community.github.io/home-manager +[mit]: https://mit-license.org +[mk-flake]: https://github.com/divnix/digga/tree/master/src/mkFlake +[nix]: https://nixos.org/manual/nix/stable +[nixos]: https://nixos.org/manual/nixos/stable +[nixpkgs]: https://github.com/NixOS/nixpkgs +[nvfetcher]: https://github.com/berberman/nvfetcher [please]: https://github.com/nrdxp/devos/tree/nrd -[matrix]: https://matrix.to/#/#devos:nixos.org + diff --git a/bud/default.nix b/bud/default.nix new file mode 100644 index 0000000..c486636 --- /dev/null +++ b/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/bud/get.bash b/bud/get.bash new file mode 100644 index 0000000..3b4d9a7 --- /dev/null +++ b/bud/get.bash @@ -0,0 +1 @@ +nix flake new -t "github:divnix/devos/core" "${2:-devos}" diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index 4766cdf..8574dae 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -1,25 +1,18 @@ # Pull Requests -All development is done in the `develop` branch. Only minor bug-fixes and release -PRs should target `master`. -If making a change to the template, or adding a feature, please be sure to update the -relevant docs. Each directory contains its own README.md, which will -automatically be pulled into the [mdbook](https://devos.divnix.com). The book is -rendered on every change, so the docs should always be up to date. +## TL;DR; +- **Target Branch**: `main` +- **Merge Policy**: [`bors`][bors] is alwyas right (→ `bors try`) +- **Docs**: every changeset is expected to contain doc updates +- **Commit Msg**: be a poet! Comprehensive and explanatory commit messages + should cover the motivation and use case in an easily understandable manner + even when read after a few months. +- **Test Driven Development**: please default to test driven development where possible. -We also use [BORS](https://bors.tech) to ensure that all pull requests pass the -test suite once at least one review is completed. +### Within the Devshell (`nix develop`) +- **Hooks**: please `git commit` within the devshell +- **Fail Early**: please run from within the devshell on your local machine: + - `nix flake check` -# Style -If you wish to contribute please follow these guidelines: +[bors]: https://bors.tech -* format your code with [`nixpkgs-fmt`][nixpkgs-fmt]. The default devshell - includes a pre-commit hook that does this for you. - -* The commit message follows the same semantics as [nixpkgs][nixpkgs]. - * You can use a `#` symbol to specify ambiguities. For example, - `develop#zsh: ` would tell me that you're updating the - `zsh` subprofile living under the `develop` profile. - -[nixpkgs-fmt]: https://github.com/nix-community/nixpkgs-fmt -[nixpkgs]: https://github.com/NixOS/nixpkgs diff --git a/doc/SUMMARY.md b/doc/SUMMARY.md index e2b6e9a..1d7bafe 100644 --- a/doc/SUMMARY.md +++ b/doc/SUMMARY.md @@ -6,7 +6,6 @@ - [Bootstrapping](./start/bootstrapping.md) - [From NixOS](./start/from-nixos.md) - [Key Concepts](./concepts/index.md) - - [Extern](./concepts/extern.md) - [Hosts](./concepts/hosts.md) - [Overrides](./concepts/overrides.md) - [Profiles](./concepts/profiles.md) @@ -17,19 +16,13 @@ - [Overlays](./outputs/overlays.md) - [Packages](./outputs/pkgs.md) - [Concerns]() - - [Lib](./lib.md) - [Secrets](./secrets.md) - [Tests](./tests.md) -- [Helper Script – `flk`](./flk/index.md) - - [up](./flk/up.md) - - [update](./flk/update.md) - - [get](./flk/get.md) - - [doi](./flk/doi.md) - - [iso](./flk/iso.md) - - [install](./flk/install.md) - - [home](./flk/home.md) +- [Helper Script – `bud`](./bud/index.md) + - [get](./bud/get.md) - [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/flk/get.md b/doc/bud/get.md similarity index 90% rename from doc/flk/get.md rename to doc/bud/get.md index 8761f00..12263df 100644 --- a/doc/flk/get.md +++ b/doc/bud/get.md @@ -4,7 +4,7 @@ git history. ## Usage ```sh -flk get DEST-DIR +bud get DEST-DIR ``` If DEST-DIR is ommitted, it defaults to _./devos_. diff --git a/doc/bud/index.md b/doc/bud/index.md new file mode 100644 index 0000000..7b98579 --- /dev/null +++ b/doc/bud/index.md @@ -0,0 +1,24 @@ +# [`bud`][bud] command +The template incudes a convenient script for managing your system called [`bud`][bud]. + +It is a portable and highly composable system control tool that work anywhere on your host +or in the flake's devshell. + +Although it comes with some predefined standard helpers, +it is very extensible and you are encouraged to write your own script snippets +to ease your workflows. An example is the bud module for a `get` command that +comes included with `devos`. + +While writing scripts you can convenientely access smart environment variables +that can tell the current architecture, user or host name, among others, regardless +wether you invoke `bud` within the devshell or as the system-wide installed `bud`. + +For details, please review the [bud repo][bud]. + +## Usage +```sh +bud help +``` + + +[bud]: https://github.com/divnix/bud diff --git a/doc/concepts/extern.md b/doc/concepts/extern.md deleted file mode 100644 index 45d8dcb..0000000 --- a/doc/concepts/extern.md +++ /dev/null @@ -1,42 +0,0 @@ -# External Art -When you need to use a module, overlay, or pass a value from one of your inputs -to the rest of your NixOS configuration, you can make use of a couple arguments. -It is encouraged to add external art directly in your `flake.nix` so the file -represents a complete dependency overview of your flake. - -## Overlays -External overlays can directly be added to a channel's `overlays` list. - -flake.nix: -```nix -{ - channels.nixos.overlays = [ inputs.agenix.overlay ]; -} -``` -Upon exporting overlays, these overlays will be automatically filtered out by inspecting the `inputs` argument. - -## Modules -There is a dedicated `nixos.hostDefaults.externalModules` argument for external -modules. - -flake.nix: -```nix -{ - nixos.hostDefaults.externalModules = [ inputs.agenix.nixosModules.age ]; -} -``` - -## Home Manager -Since there isn't a `hosts` concept for home-manager, externalModules is just a -top-level argument in the `home` namespace. - -flake.nix: -```nix -{ - home.externalModules = [ doom-emacs = doom-emacs.hmModule ]; -} -``` - -> ##### Note: -> To avoid declaring "external" modules separately, which is obvious since they come from `inputs`, the optimal solution would be to automatically export modules that were created in -> your flake. But this is not possible due to NixOS/nix#4740. diff --git a/doc/concepts/index.md b/doc/concepts/index.md index 8aca6e5..618292c 100644 --- a/doc/concepts/index.md +++ b/doc/concepts/index.md @@ -1,4 +1,10 @@ # Key Concepts -There are few idioms unique to DevOS. This section is dedicated to helping you -understand them. +Key concepts are derived from [digga][digga]. Please refer to its +[docs][digga-docs] for more details. + +This section is dedicated to helping you develop a more hands on +understanding of them them. + +[digga-docs]: https://digga.divnix.com +[digga]: https://github.com/divnix/digga diff --git a/doc/concepts/users.md b/doc/concepts/users.md index 20f371d..12bf562 100644 --- a/doc/concepts/users.md +++ b/doc/concepts/users.md @@ -1,3 +1,8 @@ +> ##### _Note:_ +> This section and its semantics need a conceptiual rework. +> Since recently [portable home configurations][portableuser] +> that are not bound to any specific host are a thing. + # Users Users are a special case of [profiles](profiles.md) that define system @@ -69,3 +74,4 @@ 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/core/users/modules/module-list.nix +[portableuser]: https://digga.divnix.com/api-reference-home.html#homeusers diff --git a/doc/flk/doi.md b/doc/flk/doi.md deleted file mode 100644 index fc522cd..0000000 --- a/doc/flk/doi.md +++ /dev/null @@ -1,10 +0,0 @@ -# DigitalOcean - -Now you can [create a droplet](https://cloud.digitalocean.com/droplets/new) using your custom image. - -Making a DigitalOcean compatible image for `hosts/NixOS.nix` is as simple as: -```sh -flk doi NixOS -``` - -This works for any file matching `hosts/*.nix` excluding `default.nix`. diff --git a/doc/flk/home.md b/doc/flk/home.md deleted file mode 100644 index f0bae76..0000000 --- a/doc/flk/home.md +++ /dev/null @@ -1,8 +0,0 @@ -# home -The `home` subcommand is for using your home-manager configurations outside of -NixOS, providing an awesome mechanism for keeping your environments -synchronized, even when using other systems. - -## Usage -The [users](../concepts/users.md#external-usage) page contains a good usage -example. diff --git a/doc/flk/index.md b/doc/flk/index.md deleted file mode 100644 index 04fc1c4..0000000 --- a/doc/flk/index.md +++ /dev/null @@ -1,20 +0,0 @@ -# flk command -The devshell for the project incudes a convenient script for managing your -system called `flk`. Each of the following chapters is a reference for one of -its subcommands. - -## Rebuild -Without any of the subcommands, `flk` acts as a convenient shortcut for -`nixos-rebuild`: -```sh -flk NixOS build -``` - -Will build _hosts/NixOS.nix_. You can change out `build` for `switch`, `test`, -etc. Any additional arguments are passed through to the call to -`nixos-rebuild`. - -## Usage -```sh -flk help -``` diff --git a/doc/flk/install.md b/doc/flk/install.md deleted file mode 100644 index 3ae5250..0000000 --- a/doc/flk/install.md +++ /dev/null @@ -1,12 +0,0 @@ -# install -The `install` subcommand is a simple convenience for `nixos-install`, similar -to the shortcut for `nixos-rebuild`, all additional arguments are passed -through. - -## Example -```sh -flk install NixOS -``` - -This will install _hosts/NixOS.nix_ to /mnt. You can override this directory -using standard `nixos-install` args. diff --git a/doc/flk/iso.md b/doc/flk/iso.md deleted file mode 120000 index fa658ef..0000000 --- a/doc/flk/iso.md +++ /dev/null @@ -1 +0,0 @@ -../start/iso.md \ No newline at end of file diff --git a/doc/flk/up.md b/doc/flk/up.md deleted file mode 100644 index 265e03a..0000000 --- a/doc/flk/up.md +++ /dev/null @@ -1,4 +0,0 @@ -# up -The `up` subcommand is a simple shortcut for `nixos-generate-config` that is -compatible with devos. There is a short explanation in the the getting started -[guide](../start/from-nixos.md#generate-configuration). diff --git a/doc/flk/update.md b/doc/flk/update.md deleted file mode 100644 index 869db72..0000000 --- a/doc/flk/update.md +++ /dev/null @@ -1,22 +0,0 @@ -# update -The `update` subcommand is a simple alias for: -```sh -nix flake update -``` -As it sounds, this will update your lock file. - -## Updating Package Sources -If you pass directory name then it will update that input if the directory -contains a flake.nix, with an optional arguement to update only a specific -input in the subflake. - -For example, you can update any -[package sources](../outputs/pkgs.md#automatic-source-updates) you may have -declared in _pkgs/flake.nix_: -```sh -flk update pkgs -``` -or just its _nixpkgs_: -```sh -flk update pkgs nixpkgs -``` diff --git a/doc/integrations/nvfetcher.md b/doc/integrations/nvfetcher.md new file mode 100644 index 0000000..4670657 --- /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/doc/mkFlakeOptions.md b/doc/mkFlakeOptions.md deleted file mode 100644 index dbc7abc..0000000 --- a/doc/mkFlakeOptions.md +++ /dev/null @@ -1,541 +0,0 @@ -## channels -nixpkgs channels to create - - -*_Type_*: -attribute set of submodules - - -*_Default_* -``` -{} -``` - - - - -## channels.\.config -nixpkgs config for this channel - - -*_Type_*: -attribute set or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## channels.\.input -nixpkgs flake input to use for this channel - - -*_Type_*: -nix flake - - -*_Default_* -``` -"self.inputs." -``` - - - - -## channels.\.overlays -overlays to apply to this channel -these will get exported under the 'overlays' flake output -as \/\ and any overlay pulled from ${inputs} -will be filtered out - - -*_Type_*: -list of valid Nixpkgs overlay or path convertible to its or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## channelsConfig -nixpkgs config for all channels - - -*_Type_*: -attribute set or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## devshell -Modules to include in your devos shell. the `modules` argument -will be exported under the `devshellModules` output - - -*_Type_*: -submodule - - -*_Default_* -``` -{} -``` - - - - -## devshell.externalModules -modules to include that won't be exported -meant importing modules from external flakes - - -*_Type_*: -list of valid module or path convertible to its or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## devshell.modules -modules to include in all hosts and export to devshellModules output - - -*_Type_*: -list of path to a modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## home -hosts, modules, suites, and profiles for home-manager - - -*_Type_*: -submodule - - -*_Default_* -``` -{} -``` - - - - -## home.externalModules -modules to include that won't be exported -meant importing modules from external flakes - - -*_Type_*: -list of valid module or path convertible to its or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## home.importables -Packages of paths to be passed to modules as `specialArgs`. - - -*_Type_*: -attribute set - - -*_Default_* -``` -{} -``` - - - - -## home.importables.suites -collections of profiles - - -*_Type_*: -attribute set of list of paths or anything convertible to its - - - - - - -## home.modules -modules to include in all hosts and export to homeModules output - - -*_Type_*: -list of path to a modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## home.profiles -WARNING: The 'suites' and `profiles` options have been deprecated, you can now create -both with the importables option. `rakeLeaves` can be used to create profiles and -by passing a module or `rec` set to `importables`, suites can access profiles. -Example: -``` -importables = rec { - profiles = digga.lib.importers.rakeLeaves ./profiles; - suites = with profiles; { }; -} -``` -See https://github.com/divnix/digga/pull/30 for more details - - -*_Type_*: -list of paths - - -*_Default_* -``` -[] -``` - - - - -## home.suites -WARNING: The 'suites' and `profiles` options have been deprecated, you can now create -both with the importables option. `rakeLeaves` can be used to create profiles and -by passing a module or `rec` set to `importables`, suites can access profiles. -Example: -``` -importables = rec { - profiles = digga.lib.importers.rakeLeaves ./profiles; - suites = with profiles; { }; -} -``` -See https://github.com/divnix/digga/pull/30 for more details - - -*_Type_*: -function that evaluates to a(n) attrs or path convertible to it - - - - - - -## nixos -hosts, modules, suites, and profiles for nixos - - -*_Type_*: -submodule - - -*_Default_* -``` -{} -``` - - - - -## nixos.hostDefaults -Defaults for all hosts. -the modules passed under hostDefaults will be exported -to the 'nixosModules' flake output. -They will also be added to all hosts. - - -*_Type_*: -submodule - - -*_Default_* -``` -{} -``` - - - - -## nixos.hostDefaults.channelName -Channel this host should follow - - -*_Type_*: -a channel defined in `channels` - - -*_Default_* -``` -null -``` - - - - -## nixos.hostDefaults.externalModules -modules to include that won't be exported -meant importing modules from external flakes - - -*_Type_*: -list of valid module or path convertible to its or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## nixos.hostDefaults.modules -modules to include in all hosts and export to nixosModules output - - -*_Type_*: -list of path to a modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## nixos.hostDefaults.system -system for this host - - -*_Type_*: -system defined in `supportedSystems` - - -*_Default_* -``` -null -``` - - - - -## nixos.hosts -configurations to include in the nixosConfigurations output - - -*_Type_*: -attribute set of submodules - - -*_Default_* -``` -{} -``` - - - - -## nixos.hosts.\.channelName -Channel this host should follow - - -*_Type_*: -a channel defined in `channels` - - -*_Default_* -``` -null -``` - - - - -## nixos.hosts.\.modules -modules to include - - -*_Type_*: -list of valid module or path convertible to its or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## nixos.hosts.\.system -system for this host - - -*_Type_*: -system defined in `supportedSystems` - - -*_Default_* -``` -null -``` - - - - -## nixos.importables -Packages of paths to be passed to modules as `specialArgs`. - - -*_Type_*: -attribute set - - -*_Default_* -``` -{} -``` - - - - -## nixos.importables.suites -collections of profiles - - -*_Type_*: -attribute set of list of paths or anything convertible to its - - - - - - -## nixos.profiles -WARNING: The 'suites' and `profiles` options have been deprecated, you can now create -both with the importables option. `rakeLeaves` can be used to create profiles and -by passing a module or `rec` set to `importables`, suites can access profiles. -Example: -``` -importables = rec { - profiles = digga.lib.importers.rakeLeaves ./profiles; - suites = with profiles; { }; -} -``` -See https://github.com/divnix/digga/pull/30 for more details - - -*_Type_*: -list of paths - - -*_Default_* -``` -[] -``` - - - - -## nixos.suites -WARNING: The 'suites' and `profiles` options have been deprecated, you can now create -both with the importables option. `rakeLeaves` can be used to create profiles and -by passing a module or `rec` set to `importables`, suites can access profiles. -Example: -``` -importables = rec { - profiles = digga.lib.importers.rakeLeaves ./profiles; - suites = with profiles; { }; -} -``` -See https://github.com/divnix/digga/pull/30 for more details - - -*_Type_*: -function that evaluates to a(n) attrs or path convertible to it - - - - - - -## outputsBuilder -builder for flake system-spaced outputs -The builder gets passed an attrset of all channels - - -*_Type_*: -function that evaluates to a(n) attrs - - -*_Default_* -``` -"channels: { }" -``` - - - - -## self -The flake to create the devos outputs for - -*_Type_*: -nix flake - - - - - - -## supportedSystems -The systems supported by this flake - - -*_Type_*: -list of strings - - -*_Default_* -``` -["aarch64-linux","i686-linux","x86_64-darwin","x86_64-linux"] -``` - - - diff --git a/doc/outputs/pkgs.md b/doc/outputs/pkgs.md index 58ce52b..548667f 100644 --- a/doc/outputs/pkgs.md +++ b/doc/outputs/pkgs.md @@ -13,16 +13,6 @@ the supported systems listed in the package's `meta.platforms` attribute. And, as usual, every package in the overlay is also available to any NixOS [host](../concepts/hosts.md). -## Automatic Source Updates -There is the added, but optional, convenience of declaring your sources in -_pkgs/flake.nix_ as an input. You can then access them from the `srcs` package. -This allows updates to be managed automatically by simply -[updating](../flk/update.md#updating-package-sources) the lock file. No -more manually entering sha256 hashes! - -As an added bonus, version strings are also generated automatically from either -the flake ref, or the date and git revision of the source. - ## Example pkgs/development/libraries/libinih/default.nix: ```nix diff --git a/doc/start/iso.md b/doc/start/iso.md index efa515a..8f5c6ab 100644 --- a/doc/start/iso.md +++ b/doc/start/iso.md @@ -2,13 +2,13 @@ Making and writing an installable iso for `hosts/NixOS.nix` is as simple as: ```sh -flk iso NixOS +bud build NixOS bootstrapIso dd bs=4M if=result/iso/*.iso of=/dev/$your_installation_device \ status=progress oflag=sync ``` -This works for any file matching `hosts/*.nix` excluding `default.nix`. +This works for any host. ## ISO image nix store & cache diff --git a/flake.lock b/flake.lock index 2a722b2..2a465ae 100644 --- a/flake.lock +++ b/flake.lock @@ -20,31 +20,42 @@ "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" - }, + "blank": { "locked": { - "lastModified": 1624885917, - "narHash": "sha256-CaAEhMKzuTyN9krTLZ1jWW3C5HzvKRZY/doVOezZZx0=", - "owner": "hercules-ci", - "repo": "hercules-ci-agent", - "rev": "5eba6597af97e358542c6f968f6ef680ffd2a401", + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-agent", + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "bud": { + "inputs": { + "devshell": [ + "digga", + "devshell" + ], + "nixpkgs": [ + "nixos" + ] + }, + "locked": { + "lastModified": 1627855680, + "narHash": "sha256-snDOrUp8nth2Vs3GeEXr7Xji+HaHy25htZLNvid/U3I=", + "owner": "divnix", + "repo": "bud", + "rev": "612228a68d404d559405225427a5d8b3cef9d27c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "bud", "type": "github" } }, @@ -70,17 +81,23 @@ }, "deploy": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "naersk": "naersk", - "nixpkgs": "nixpkgs", - "utils": "utils" + "nixpkgs": [ + "digga", + "nixpkgs" + ], + "utils": [ + "digga", + "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": { @@ -91,11 +108,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": { @@ -106,38 +123,47 @@ }, "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": 1627484795, + "narHash": "sha256-ZnErne4CWPxN3G6jwEzSeTD++iIXdRa9+5ZTp2IuOQ0=", "owner": "divnix", "repo": "digga", - "rev": "f69703abc33f221b676966a8435c4f09ef70ff49", + "rev": "b52bb1001950eae6aca993232c1a88d0638b1dcf", "type": "github" }, "original": { "owner": "divnix", - "ref": "master", "repo": "digga", "type": "github" } }, "fenix": { "inputs": { - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs", "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1626921046, - "narHash": "sha256-B8aPIafJiJw9sBsPL84mNclBN04UiMBpHDmmZNxZfzE=", + "lastModified": 1628133869, + "narHash": "sha256-hRJ//lpsd8ACK4GOZIknGZjey3OFYJ2fYBPEqg/JC7o=", "owner": "nix-community", "repo": "fenix", - "rev": "17a814fb3b750c370942dc9bb9693befe14b2c0a", + "rev": "9e13d0cb62b00e7f38d920c9fc3a642ee4797be8", "type": "github" }, "original": { @@ -162,34 +188,40 @@ "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": [ + "digga", + "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" } }, @@ -200,33 +232,33 @@ ] }, "locked": { - "lastModified": 1625516974, - "narHash": "sha256-hq4eAl7wJoGwjtHCdqItjb81XgjVL5K79NX3jSmNRMA=", + "lastModified": 1624228557, + "narHash": "sha256-wwOqe73BsrXfRv1PhyXQFNC8iTET50KvE/HitdkRgxs=", "owner": "nix-community", "repo": "home-manager", - "rev": "97d183e2e466808f5d7cd1c838815bedd88f37fe", + "rev": "35a24648d155843a4d162de98c17b1afd5db51e4", "type": "github" }, "original": { "owner": "nix-community", + "ref": "release-21.05", "repo": "home-manager", "type": "github" } }, "latest": { "locked": { - "lastModified": 1626852498, - "narHash": "sha256-lOXUJvi0FJUXHTVSiC5qsMRtEUgqM4mGZpMESLuGhmo=", + "lastModified": 1627391865, + "narHash": "sha256-tPoWBO9Nzu3wuX37WcnctzL6LoDCErJLnfLGqqmXCm4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "16105403bdd843540cbef9c63fc0f16c1c6eaa70", + "rev": "8ecc61c91a596df7d3293603a9c2384190c1b89a", "type": "github" }, "original": { - "owner": "NixOS", + "id": "nixpkgs", "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "indirect" } }, "naersk": { @@ -236,11 +268,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": { @@ -270,34 +302,43 @@ "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, - "narHash": "sha256-lOXUJvi0FJUXHTVSiC5qsMRtEUgqM4mGZpMESLuGhmo=", + "lastModified": 1627930555, + "narHash": "sha256-JKS4wNmSnkatz+3G5g0/o+tXg3XpQ4AtBpgbw2+kIcw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "16105403bdd843540cbef9c63fc0f16c1c6eaa70", + "rev": "c15e294a60abc894964f4b0ae0ca17dc18b9ca98", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", + "id": "nixpkgs", + "ref": "release-21.05", + "type": "indirect" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": [ + "digga", + "nixlib" + ], + "nixpkgs": [ + "digga", + "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" } }, @@ -318,42 +359,11 @@ }, "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" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1620962350, - "narHash": "sha256-9ASW4d4/Z8HmRvuJI8rxbEOTbXTBpQ8y+CmFYBwtXzE=", + "lastModified": 1627942574, + "narHash": "sha256-guUcGRWvY2mfiVSet2x/zeHIyflm2wgglj0ldg0mMio=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5d4a430472cafada97888cc80672fab255231f57", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1626852498, - "narHash": "sha256-lOXUJvi0FJUXHTVSiC5qsMRtEUgqM4mGZpMESLuGhmo=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "16105403bdd843540cbef9c63fc0f16c1c6eaa70", + "rev": "c464dc811babfe316ed4ab7bbc12351122e69dd7", "type": "github" }, "original": { @@ -363,77 +373,82 @@ "type": "github" } }, - "nur": { - "locked": { - "lastModified": 1625630921, - "narHash": "sha256-1eZPDLRPK8bXDDLuvd+hx2MXv/aeG1I0uK82PMyP0n4=", - "owner": "nix-community", - "repo": "NUR", - "rev": "67cfb2adc5ee22aeb4ab87d47352991ef75620d2", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "NUR", - "type": "github" - } - }, - "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": 1627523399, + "narHash": "sha256-j9CgnUQpWcb8OB4LRzPW8BdxvmoROJptgptDlPA8Heo=", + "owner": "berberman", + "repo": "nvfetcher", + "rev": "fb8f2cc770ad3dd3e29d7ba3004692d4d53fba9b", "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", "fenix": "fenix", + "flake-utils": [ + "digga", + "flake-utils" + ], + "flake-utils-plus": [ + "digga", + "flake-utils-plus" + ], "home": "home", "latest": "latest", "naersk": "naersk_2", + "nixlib": [ + "digga", + "nixlib" + ], "nixos": "nixos", "nixos-hardware": "nixos-hardware", - "nur": "nur", - "pkgs": "pkgs" + "nixpkgs": [ + "nixos" + ], + "nvfetcher": "nvfetcher" } }, "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1626896519, - "narHash": "sha256-dodPO28s//aP8RtYt2L/CU95cP1IsAwnVHLO91hSxww=", + "lastModified": 1628100757, + "narHash": "sha256-fBceHf8ZH9mKmuLjI4XabdpUL2jsjwtb5Ku+kXxnI/o=", "owner": "rust-analyzer", "repo": "rust-analyzer", - "rev": "a36c9d8b5ce8f6468f9387fab590ad48381c1313", + "rev": "950efff5c6f1fdc803d7abda3adf4e60899dadb0", "type": "github" }, "original": { @@ -442,40 +457,6 @@ "repo": "rust-analyzer", "type": "github" } - }, - "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" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4457c23..cf03858 100644 --- a/flake.nix +++ b/flake.nix @@ -1,125 +1,156 @@ { description = "A highly structured configuration database."; + nixConfig.extra-experimental-features = "nix-command flakes ca-references"; inputs = { - nixos.url = "github:NixOS/nixpkgs/nixos-unstable"; - latest.url = "github:NixOS/nixpkgs/nixos-unstable"; - digga.url = "github:divnix/digga/master"; + nixos.url = "nixpkgs/release-21.05"; + latest.url = "nixpkgs/nixos-unstable"; + + 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"; - ci-agent = { - url = "github:hercules-ci/hercules-ci-agent"; - inputs = { nix-darwin.follows = "darwin"; nixos-20_09.follows = "nixos"; nixos-unstable.follows = "latest"; }; - }; 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"; - nur.url = github:nix-community/NUR; - fenix.url = "github:nix-community/fenix"; - pkgs.url = "path:./pkgs"; - pkgs.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 + + fenix.url = "github:nix-community/fenix"; }; outputs = { self - , pkgs , digga + , bud , nixos - , ci-agent , home , nixos-hardware - , nur , agenix , fenix + , nvfetcher + , deploy , ... } @ inputs: - digga.lib.mkFlake { - inherit self inputs; + digga.lib.mkFlake + { + inherit self inputs; - channelsConfig = { allowUnfree = true; }; + channelsConfig = { allowUnfree = true; }; + + channels = { + nixos = { + imports = [ (digga.lib.importOverlays ./overlays) ]; + overlays = [ + digga.overlays.patchedNix + agenix.overlay + nvfetcher.overlay + deploy.overlay + ./pkgs/default.nix + + fenix.overlay + ]; + }; + 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 - agenix.overlay - fenix.overlay - ]; - }; - latest = { }; - }; - - lib = import ./lib { lib = digga.lib // nixos.lib; }; - - 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 - 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; + 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 + ]; }; - suites = (import ./suites) { inherit profiles; }; - }; - }; - - home = { - modules = ./users/modules/module-list.nix; - externalModules = [ ]; - importables = rec { - profiles = digga.lib.importers.rakeLeaves ./users/profiles; - suites = with profiles; rec { - base = [ direnv git ]; + 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 = (import ./suites) { inherit profiles; }; }; }; - }; - devshell.externalModules = { pkgs, ... }: { - packages = [ pkgs.agenix ]; - }; + home = { + imports = [ (digga.lib.importModules ./users/modules) ]; + externalModules = [ ]; + importables = rec { + profiles = digga.lib.rakeLeaves ./users/profiles; + suites = with profiles; rec { + base = [ direnv git ]; + }; + }; + users = { + nixos = { suites, ... }: { imports = suites.base; }; + }; # digga.lib.importers.rakeLeaves ./users/hm; + }; - homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; + devshell = ./shell; - deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; + homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; - defaultTemplate = self.templates.flk; - templates.flk.path = ./.; - templates.flk.description = "flk template"; + deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; + defaultTemplate = self.templates.bud; + templates.bud.path = ./.; + templates.bud.description = "bud template"; + + } + // + { + budModules = { devos = import ./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/module-list.nix b/modules/module-list.nix deleted file mode 100644 index 1e3ec72..0000000 --- a/modules/module-list.nix +++ /dev/null @@ -1 +0,0 @@ -[ ] 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 629f44b..6280513 100644 --- a/overlays/overrides.nix +++ b/overlays/overrides.nix @@ -7,7 +7,6 @@ channels: final: prev: { dhall discord element-desktop - manix rage nixpkgs-fmt qutebrowser @@ -15,15 +14,15 @@ channels: final: prev: { starship; - haskellPackages = prev.haskellPackages.override { - overrides = 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; - }; - }; - + 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; + }); + }); } 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..71be396 --- /dev/null +++ b/pkgs/_sources/generated.nix @@ -0,0 +1,16 @@ +# 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/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 222e921..5157dec 100644 --- a/profiles/core/default.nix +++ b/profiles/core/default.nix @@ -14,8 +14,8 @@ in systemPackages = with pkgs; [ binutils coreutils + psmisc curl - killall direnv dnsutils dosfstools @@ -24,7 +24,7 @@ in git bat neovim - gotop + bottom gptfdisk file iputils @@ -41,7 +41,6 @@ in nixpkgs-fmt libqalculate - nur.repos.xe.comma ]; }; 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..128b45c --- /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 $@"; + } + (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;