···11{ inputs, lib, ... }:
22-if inputs ? flake-parts then
33- { }
44-else
55- {
66- # NOTE: Currently Den needs a top-level attribute where to place configurations,
77- # by default it is the `flake` attribute, even if Den uses no flake-parts at all.
88-99- # This definitions has been adapted from https://github.com/hercules-ci/flake-parts
1010- # project which is licensed with:
1111- #
1212- # MIT License
1313- #
1414- # Copyright (c) 2021 Hercules CI
1515- #
1616- # Permission is hereby granted, free of charge, to any person obtaining a copy
1717- # of this software and associated documentation files (the "Software"), to deal
1818- # in the Software without restriction, including without limitation the rights
1919- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2020- # copies of the Software, and to permit persons to whom the Software is
2121- # furnished to do so, subject to the following conditions:
2222- #
2323- # The above copyright notice and this permission notice shall be included in all
2424- # copies or substantial portions of the Software.
2525- #
2626- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2727- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2828- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2929- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3030- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3131- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3232- # SOFTWARE.
3333- options.flake = lib.mkOption {
3434- type = lib.types.submoduleWith {
3535- modules = [
3636- {
3737- freeformType = lib.types.lazyAttrsOf (
3838- lib.types.unique {
3939- message = ''
4040- No option has been declared for this flake output attribute, so its definitions can't be merged automatically.
4141- Possible solutions:
4242- - Load a module that defines this flake output attribute
4343- - Declare an option for this flake output attribute
4444- - Make sure the output attribute is spelled correctly
4545- - Define the value only once, with a single definition in a single module
4646- '';
4747- } lib.types.raw
4848- );
4949- }
5050- ];
5151- };
5252- };
5353- }
22+let
33+ has-flake-parts = inputs ? flake-parts;
44+ outputOptions.flake = lib.mkOption {
55+ default = { };
66+ type = lib.types.submodule { freeformType = lib.types.lazyAttrsOf lib.types.unspecified; };
77+ };
88+in
99+{
1010+ options = lib.optionalAttrs (!has-flake-parts) outputOptions;
1111+}
+12
templates/noflake/README.md
···1212npins update den # make sure you use latest Den
1313```
14141515+This template provides runnable apps for each host/home (see modules/nh.nix)
1616+1717+```shell
1818+# default action is `build`
1919+nix-run . -A den.sh --run igloo
2020+2121+# you can specify any other action like `switch`, `repl`, `build`, `--help`
2222+nix-run . -A den.sh --run 'igloo build'
2323+```
2424+2525+or
2626+1527```shell
1628nixos-rebuild build --file . -A flake.nixosConfigurations.igloo
1729```
+18-3
templates/noflake/modules/den.nix
···11-{ inputs, ... }:
11+{ den, inputs, ... }:
22{
33 # we can import this flakeModule even if we dont have flake-parts as input!
44 imports = [ inputs.den.flakeModule ];
···11111212 # tux user on igloo host, using nix-maid
1313 den.hosts.x86_64-linux.igloo.users.tux.classes = [ "maid" ];
1414+ # tux on iceberg host with NixOS user environment
1515+ den.hosts.x86_64-linux.iceberg.users.tux.classes = [ "user" ];
1616+1717+ # first: `npins add -n darwin github nix-darwin nix-darwin`
1818+ # den.hosts.aarch64-darwin.apple.users.tux.classes = [ "hjem" ];
14191520 # host aspect
1621 den.aspects.igloo = {
···25302631 # user aspect
2732 den.aspects.tux = {
2828- # user configures host nixos.users.users.tux.isNormalUser.
3333+ # den batteries or your own re-usable aspects
3434+ includes = [ den.provides.define-user ];
3535+3636+ # user configures host <nixos/darwin>.users.users.tux.description
2937 # Read docs about the `user` class.
3030- user.isNormalUser = true;
3838+ user.description = "Cute Penguin";
3939+4040+ # user contributes nixos and darwin common config
4141+ os =
4242+ { pkgs, ... }:
4343+ {
4444+ environment.systemPackages = [ pkgs.hello ];
4545+ };
31463247 # maid class
3348 maid.file.home.".gitconfig".text = ''