Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Darwin/macOS Hosts #438

Merged
merged 34 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
71874ad
ci: run on `macos-latest`
Jan 22, 2022
4b865dd
inputs: add nix-darwin
Jan 22, 2022
7b0cff8
inputs: add nixpkgs-unstable
montchr Mar 31, 2022
7ad166f
inputs: avoid pinning nixpkgs to `latest` unless absolutely necessary
montchr Apr 4, 2022
f980b60
devshell: pin `devshell.inputs.nixpkgs` to ours
montchr Apr 4, 2022
eceb533
docs: add commands to generate darwin api docs
Jan 22, 2022
93df57f
docs: reword overlays doc to work better with syntax highlighting
Jan 22, 2022
55f1ffa
darwin: agnostic arg name for `mkHomeConfigurations`
Jan 22, 2022
251395e
darwin: add top-level option for `darwin` host type
Jan 22, 2022
1c977a3
refactor: prepare host configs in fup adapter
Jan 23, 2022
223920b
darwin: relocate nixos-only defs out of `globalDefaults` module
Jan 24, 2022
2de29e5
fix: check for `domain` attr before use
Feb 1, 2022
dec17c2
refactor: isolate exported modules to host-type-specific files
montchr Apr 1, 2022
d506813
mkFlake: require unique hostnames across nixos and darwin hosts
montchr Apr 10, 2022
a304ae0
groupByConfig: add darwin host
Jan 22, 2022
0fede41
feat: pass fup's `mergeAny` through lib output
Jan 29, 2022
fbfcbd8
docs: comments and formatting
montchr Feb 28, 2022
1246668
devos: add a darwin host + separate os-specific configs
montchr Mar 31, 2022
ab39edf
devshell: use nix 2.7 from unstable channel
montchr Mar 31, 2022
1aa990d
chore: clean up unnecessary args to deprecated.nix
montchr Apr 1, 2022
b8d1c7d
darwin: update `mkDeployNodes` to account for darwin hosts
montchr Apr 4, 2022
68ade18
devos: devshell: add required pkgs to scope explicitly
montchr Apr 4, 2022
780620d
devos: devshell: use platform checks from `stdenv`
montchr Apr 4, 2022
4438b0f
devos: devshell: reorder + cleanup
montchr Apr 4, 2022
698551e
feat: add function to filter hosts from an attrset by system
montchr Apr 10, 2022
b4f74f5
darwin: avoid checking unsupported flake outputs
montchr Apr 10, 2022
41a49ae
devos: darwin-specific profile customizations
montchr Apr 19, 2022
8232e94
chore: docs + formatting
montchr Apr 21, 2022
89d9b3e
devos: move common overlays to `sharedOverlays` for fup passthrough
montchr Apr 23, 2022
139d6e6
docs: update api references
montchr Apr 24, 2022
dd8d0b7
chore: update inputs
montchr Apr 24, 2022
64bd638
darwin: standardize nix-darwin input and nixpkgs-darwin-stable usages
montchr Apr 27, 2022
e6b14d3
devos: override `nix-index` pkg with latest
montchr Apr 27, 2022
580fc57
chore: restore examples digga input branch to main
montchr Apr 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ on:

jobs:
check:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest]
steps:

- uses: actions/checkout@v3
Expand Down
13 changes: 6 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ let
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
) defaultNix;
{ src = ./.; }) defaultNix;
in
# Pass this flake as inputs.digga
defaultNix // {
inputs = defaultNix.inputs // { digga = defaultNix; };
shell = import ./devShell.nix { };
}
# Pass this flake as inputs.digga
defaultNix // {
inputs = defaultNix.inputs // { digga = defaultNix; };
shell = import ./devShell.nix { };
}

2 changes: 1 addition & 1 deletion deprecated.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, flake-utils-plus, internal-modules, importers, nixosModules }:
{ lib, importers }:
lib.warn ''
You are accessing a deprecated item of the digga lib.
Please update timely, it will be remove soon.
Expand Down
14 changes: 8 additions & 6 deletions devShell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
, inputs ? (import ./.).inputs
}:
let

pkgs = inputs.nixpkgs.legacyPackages.${system};
devshell = import inputs.devshell { inherit pkgs system; };
unstablePkgs = inputs.nixpkgs-unstable.legacyPackages.${system};
devshell = import inputs.devshell { inherit system; };
nixBin = "${unstablePkgs.nix}/bin/nix";

withCategory = category: attrset: attrset // { inherit category; };
utils = withCategory "utils";
Expand Down Expand Up @@ -79,9 +80,9 @@ let
digga_fixture

test -f flake.lock && lockfile_present=$? || true
${pkgs.nixUnstable}/bin/nix flake lock --update-input digga "$@"; lockfile_updated=$?;
${pkgs.nixUnstable}/bin/nix flake show "$@"
${pkgs.nixUnstable}/bin/nix flake check "$@"
${nixBin} flake lock --update-input digga "$@"; lockfile_updated=$?;
${nixBin} flake show "$@"
${nixBin} flake check "$@"

cleanup
'';
Expand All @@ -93,7 +94,8 @@ devshell.mkShell {
packages = with pkgs; [
fd
nixpkgs-fmt
nixUnstable
# Use the latest stable version of nix
unstablePkgs.nix
];

env = [
Expand Down
18 changes: 17 additions & 1 deletion doc/api-reference-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ nix flake
## channels.\<name\>.overlays
overlays to apply to this channel
these will get exported under the 'overlays' flake output
as \<channel\>/\<name\> and any overlay pulled from ${inputs}
as \<channel\>/\<name\> and any overlay pulled from \<inputs\>
will be filtered out


Expand All @@ -73,3 +73,19 @@ list of valid Nixpkgs overlay or path convertible to its or anything convertible



## channels.\<name\>.patches
patches to apply to this channel


*_Type_*:
list of paths


*_Default_*
```
[]
```




48 changes: 0 additions & 48 deletions doc/api-reference-home.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,54 +101,6 @@ list of valid modules or anything convertible to it or path convertible to it



## 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.rakeLeaves ./profiles;
suites = with profiles; { };
}
```
See https://github.com/divnix/digga/pull/30 for more details


*_Type_*:
list of paths or path convertible to it


*_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.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






## home.users
HM users that can be deployed portably without a host.

Expand Down
48 changes: 0 additions & 48 deletions doc/api-reference-nixos.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,51 +232,3 @@ null



## 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.rakeLeaves ./profiles;
suites = with profiles; { };
}
```
See https://github.com/divnix/digga/pull/30 for more details


*_Type_*:
list of paths or path convertible to it


*_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.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






3 changes: 2 additions & 1 deletion doc/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Home](./api-reference-home.md)
- [Devshell](./api-reference-devshell.md)
- [NixOS](./api-reference-nixos.md)
- [Darwin](./api-reference-darwin.md)

## channelsConfig
nixpkgs config for all channels
Expand Down Expand Up @@ -39,7 +40,7 @@ The builder gets passed an attrset of all channels


*_Type_*:
function that evaluates to a(n) attrs or path convertible to it
function that evaluates to a(n) attribute set or path convertible to it


*_Default_*
Expand Down
84 changes: 73 additions & 11 deletions examples/devos/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
# Track channels with commits tested and built by hydra
nixos.url = "github:nixos/nixpkgs/nixos-21.11";
latest.url = "github:nixos/nixpkgs/nixos-unstable";
# For darwin hosts: it can be helpful to track this darwin-specific stable
# channel equivalent to the `nixos-*` channels for NixOS. For one, these
# channels are more likely to provide cached binaries for darwin systems.
# But, perhaps even more usefully, it provides a place for adding
# darwin-specific overlays and packages which could otherwise cause build
# failures on Linux systems.
nixpkgs-darwin-stable.url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin";

digga.url = "github:divnix/digga";
digga.inputs.nixpkgs.follows = "nixos";
Expand All @@ -25,7 +32,7 @@
home.inputs.nixpkgs.follows = "nixos";

darwin.url = "github:LnL7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixos";
darwin.inputs.nixpkgs.follows = "nixpkgs-darwin-stable";

deploy.url = "github:serokell/deploy-rs";
deploy.inputs.nixpkgs.follows = "nixos";
Expand Down Expand Up @@ -55,6 +62,7 @@
, agenix
, nvfetcher
, deploy
, nixpkgs
, ...
} @ inputs:
digga.lib.mkFlake
Expand All @@ -66,12 +74,11 @@
channels = {
nixos = {
imports = [ (digga.lib.importOverlays ./overlays) ];
overlays = [
nur.overlay
agenix.overlay
nvfetcher.overlay
./pkgs/default.nix
];
overlays = [ ];
};
nixpkgs-darwin-stable = {
imports = [ (digga.lib.importOverlays ./overlays) ];
overlays = [ ];
};
latest = { };
};
Expand All @@ -85,6 +92,12 @@
our = self.lib;
});
})

nur.overlay
agenix.overlay
nvfetcher.overlay

(import ./pkgs)
];

nixos = {
Expand All @@ -102,17 +115,45 @@
];
};

imports = [ (digga.lib.importHosts ./hosts) ];
imports = [ (digga.lib.importHosts ./hosts/nixos) ];
hosts = {
/* set host specific properties here */
/* set host-specific properties here */
NixOS = { };
};
importables = rec {
profiles = digga.lib.rakeLeaves ./profiles // {
users = digga.lib.rakeLeaves ./users;
};
suites = with profiles; rec {
base = [ core users.nixos users.root ];
base = [ core.nixos users.nixos users.root ];
};
};
};

darwin = {
hostDefaults = {
system = "x86_64-darwin";
channelName = "nixpkgs-darwin-stable";
imports = [ (digga.lib.importExportableModules ./modules) ];
modules = [
{ lib.our = self.lib; }
digga.darwinModules.nixConfig
home.darwinModules.home-manager
agenix.nixosModules.age
];
};

imports = [ (digga.lib.importHosts ./hosts/darwin) ];
hosts = {
/* set host-specific properties here */
Mac = { };
};
importables = rec {
profiles = digga.lib.rakeLeaves ./profiles // {
users = digga.lib.rakeLeaves ./users;
};
suites = with profiles; rec {
base = [ core.darwin users.darwin ];
};
};
};
Expand All @@ -127,13 +168,34 @@
};
};
users = {
# TODO: does this naming convention still make sense with darwin support?
#
# - it doesn't make sense to make a 'nixos' user available on
# darwin, and vice versa
#
# - the 'nixos' user might have special significance as the default
# user for fresh systems
#
# - perhaps a system-agnostic home-manager user is more appropriate?
# something like 'primaryuser'?
#
# all that said, these only exist within the `hmUsers` attrset, so
# it could just be left to the developer to determine what's
# appropriate. after all, configuring these hm users is one of the
# first steps in customizing the template.
nixos = { suites, ... }: { imports = suites.base; };
darwin = { suites, ... }: { imports = suites.base; };
}; # digga.lib.importers.rakeLeaves ./users/hm;
};

devshell = ./shell;

homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations;
# TODO: similar to the above note: does it make sense to make all of
# these users available on all systems?
homeConfigurations = digga.lib.mergeAny
(digga.lib.mkHomeConfigurations self.darwinConfigurations)
(digga.lib.mkHomeConfigurations self.nixosConfigurations)
;

deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { };

Expand Down
6 changes: 6 additions & 0 deletions examples/devos/hosts/darwin/Mac.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ config, pkgs, suites, ... }:

{
imports = with suites;
base;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# interface that has the local link to the target machine
imports = [
# profiles.networking
profiles.core
profiles.core.nixos
profiles.users.root # make sure to configure ssh keys
profiles.users.nixos
];
Expand Down
Loading