Skip to content

Commit 4daa53d

Browse files
authored
Try #438:
2 parents 9da3840 + 4547745 commit 4daa53d

File tree

19 files changed

+288
-52
lines changed

19 files changed

+288
-52
lines changed

.github/workflows/check.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ on:
99

1010
jobs:
1111
check:
12-
runs-on: ubuntu-latest
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
os: [ubuntu-latest, macos-latest]
1317
steps:
1418
- uses: actions/checkout@v2.4.0
1519
with:

devshell/flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
nix build "$PRJ_ROOT#jobs.${system}.mkApiReferenceNixos" \
4141
&& cp result "$PRJ_ROOT/doc/api-reference-nixos.md" \
4242
&& chmod 755 "$PRJ_ROOT//doc/api-reference-nixos.md"
43+
nix build "$PRJ_ROOT#jobs.${system}.mkApiReferenceDarwin" \
44+
&& cp result "$PRJ_ROOT/doc/api-reference-darwin.md" \
45+
&& chmod 755 "$PRJ_ROOT//doc/api-reference-darwin.md"
4346
'';
4447
};
4548

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ self, inputs, ... }:
2+
3+
let
4+
inherit (inputs.digga.lib) allProfilesTest;
5+
in
6+
7+
{
8+
imports = [ (inputs.digga.lib.importHosts ./hosts) ];
9+
10+
hostDefaults = {
11+
channelName = "nixpkgs-darwin-stable";
12+
};
13+
14+
hosts = {
15+
"Darwinia" = { };
16+
17+
# TODO: should we expect these tests to work on darwin? any platform limitations?
18+
# Darwinia.tests = [ allProfilesTest ];
19+
Darwinia.tests = [ ];
20+
};
21+
22+
importables = rec {
23+
profiles = inputs.digga.lib.rakeLeaves ./profiles;
24+
suites = with profiles; rec {
25+
base = [ core ];
26+
};
27+
};
28+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{ config, pkgs, suites, ... }:
2+
3+
{
4+
imports = suites.base;
5+
6+
# On darwin, sudoers/admins are added to the `admin` group, not `wheel` as
7+
# they would be on Linux.
8+
nix.trustedUsers = [ "@admin" "sosumi" ];
9+
10+
# https://daiderd.com/nix-darwin/manual/index.html#opt-system.stateVersion
11+
system.stateVersion = 4;
12+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ config, lib, pkgs, ... }:
2+
3+
{
4+
# Recreate /run/current-system symlink after boot
5+
services.activate-system.enable = true;
6+
services.nix-daemon.enable = true;
7+
users.nix.configureBuildUsers = true;
8+
9+
environment.systemPackages = with pkgs; [
10+
coreutils
11+
curl
12+
direnv
13+
git
14+
gnupg
15+
gnused
16+
gnutar
17+
mas
18+
wget
19+
];
20+
21+
# Because sometimes we must
22+
homebrew = {
23+
enable = true;
24+
autoUpdate = true;
25+
global.noLock = true;
26+
};
27+
}

examples/groupByConfig/flake.nix

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
{
22
description = "A DevOS example. And also a digga test bed.";
33

4-
inputs =
5-
{
6-
nixos.url = "github:nixos/nixpkgs/release-21.11";
7-
digga = {
8-
url = "github:divnix/digga";
9-
inputs.nixpkgs.follows = "nixos";
10-
};
11-
home.url = "github:nix-community/home-manager";
12-
home.inputs.nixpkgs.follows = "nixos";
4+
inputs = {
5+
# Stable branch for the most recent NixOS release.
6+
nixos.url = "github:NixOS/nixpkgs/release-21.11";
7+
8+
# For darwin hosts: it can be helpful to track this darwin-specific stable
9+
# channel akin to the NixOS release channel. For one, it's more likely to
10+
# provide cached binaries for darwin systems. But, perhaps even more
11+
# usefully, it provides a place for adding darwin-specific overlays and
12+
# packages which could otherwise cause build failures on Linux systems.
13+
nixpkgs-darwin-stable.url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin";
14+
15+
digga = {
16+
url = "github:divnix/digga";
17+
inputs.nixpkgs.follows = "nixos";
1318
};
1419

15-
outputs = inputs @ { self, nixos, digga, home }:
20+
home.url = "github:nix-community/home-manager";
21+
home.inputs.nixpkgs.follows = "nixos";
22+
};
23+
24+
outputs =
25+
inputs @ { self
26+
, nixos
27+
, nixpkgs-darwin-stable
28+
, digga
29+
, home
30+
}:
1631
digga.lib.mkFlake {
1732

1833
inherit self inputs;
1934

20-
channels.nixos = { };
35+
channels = {
36+
nixos = { };
37+
nixpkgs-darwin-stable = { };
38+
};
2139

2240
nixos = ./nixos;
41+
darwin = ./darwin;
2342
home = ./home;
2443
devshell = ./devshell;
2544

examples/groupByConfig/nixos/default.nix

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
{ self, inputs, ... }:
2+
23
let
34
inherit (inputs.digga.lib) allProfilesTest;
45
in
6+
57
{
6-
hostDefaults.channelName = "nixos";
8+
imports = [ (inputs.digga.lib.importHosts ./hosts) ];
9+
10+
hostDefaults = {
11+
channelName = "nixos";
12+
};
13+
714
hosts = {
8-
Morty.modules = [ ./Morty.nix ];
9-
Morty.tests = [ allProfilesTest ];
15+
"Morty" = {
16+
tests = [ allProfilesTest ];
17+
};
1018
};
19+
1120
importables = rec {
1221
suites = rec {
1322
base = [ ];

flake.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
home-manager.url = "github:nix-community/home-manager/release-21.11";
2020
home-manager.inputs.nixpkgs.follows = "nixlib";
2121

22+
# for its `darwin.lib.darwinSystem` builder
23+
# TODO: update url once https://github.com/LnL7/nix-darwin/pull/429 is merged
24+
darwin.url = "github:montchr/nix-darwin/add-toplevel-option-lib";
25+
darwin.inputs.nixpkgs.follows = "latest";
26+
2227
devshell.url = "github:numtide/devshell";
2328
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
2429

@@ -40,6 +45,7 @@
4045
, devshell
4146
, flake-utils-plus
4247
, nixos-generators
48+
, darwin
4349
, home-manager
4450
, ...
4551
}@inputs:
@@ -66,7 +72,7 @@
6672
mkFlake' = import ./src/mkFlake {
6773
inherit (nixlib) lib;
6874
inherit (flake-utils-plus.inputs) flake-utils;
69-
inherit deploy devshell home-manager flake-utils-plus internal-modules tests;
75+
inherit darwin deploy devshell home-manager flake-utils-plus internal-modules tests;
7076
};
7177
in
7278
{
@@ -105,7 +111,7 @@
105111
# what you came for ...
106112
lib = {
107113
inherit (flake-utils-plus.inputs.flake-utils.lib) defaultSystems eachSystem eachDefaultSystem filterPackages;
108-
inherit (flake-utils-plus.lib) exportModules exportOverlays exportPackages;
114+
inherit (flake-utils-plus.lib) exportModules exportOverlays exportPackages mergeAny;
109115
inherit mkFlake;
110116
inherit (tests) mkTest allProfilesTest;
111117
inherit (importers) flattenTree rakeLeaves importOverlays importExportableModules importHosts;
@@ -121,6 +127,7 @@
121127
# a little extra service ...
122128
overlays = import ./overlays { inherit inputs; };
123129
nixosModules = import ./modules;
130+
darwinModules = import ./modules;
124131

125132
defaultTemplate = self.templates.devos;
126133
templates.devos.path = ./examples/devos;

jobs/default.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ in
3030
- [Home](./api-reference-home.md)
3131
- [Devshell](./api-reference-devshell.md)
3232
- [NixOS](./api-reference-nixos.md)
33+
- [Darwin](./api-reference-darwin.md)
3334
3435
${( pkgs.nixosOptionsDoc {
3536
options = {
@@ -60,5 +61,8 @@ in
6061
mkApiReferenceNixos = mkDocPartMd "nixos" "NixOS API Container" ''
6162
Configure your nixos modules, profiles & suites.
6263
'';
64+
mkApiReferenceDarwin = mkDocPartMd "darwin" "Darwin API Container" ''
65+
Configure your darwin/macOS modules, profiles & suites.
66+
'';
6367

6468
}

modules/bootstrap-iso.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let
33
let
44
net = config.networking;
55
fqdn =
6-
if net.domain != null
6+
if (net ? domain) && (net.domain != null)
77
then "${net.hostName}.${net.domain}"
88
else net.hostName;
99
in

overlays/default.nix

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
{ inputs }: {
2-
3-
}
1+
{ inputs }: { }

src/generators.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ let
44
let
55
net = c.config.networking;
66
fqdn =
7-
if net.domain != null
7+
if (net ? domain) && (net.domain != null)
88
then "${net.hostName}.${net.domain}"
99
else net.hostName;
1010
in
1111
fqdn;
1212

1313
in
1414
{
15-
mkHomeConfigurations = nixosConfigurations:
15+
mkHomeConfigurations = systemConfigurations:
1616
/**
17-
Synopsis: mkHomeConfigurations _nixosConfigurations_
17+
Synopsis: mkHomeConfigurations _systemConfigurations_
1818
1919
Generate the `homeConfigurations` attribute expected by
20-
`home-manager` cli from _nixosConfigurations_ in the form
21-
_user@hostname_.
20+
`home-manager` cli from _nixosConfigurations_ or _darwinConfigurations_
21+
in the form _user@hostname_.
2222
**/
2323
let
2424
op = attrs: c:
@@ -35,7 +35,7 @@ in
3535
;
3636
mkHmConfigs = lib.foldl op { };
3737
in
38-
mkHmConfigs (builtins.attrValues nixosConfigurations);
38+
mkHmConfigs (builtins.attrValues systemConfigurations);
3939

4040
mkDeployNodes = hosts: extraConfig:
4141
/**

src/mkFlake/default.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
{ lib, deploy, devshell, home-manager, flake-utils-plus, flake-utils, internal-modules, tests } @ injectedDeps:
1+
{ lib
2+
, darwin
3+
, deploy
4+
, devshell
5+
, home-manager
6+
, flake-utils-plus
7+
, flake-utils
8+
, internal-modules
9+
, tests
10+
} @ injectedDeps:
211

312
{ self, inputs, ... } @ args:
413
let

0 commit comments

Comments
 (0)