mirror of
https://github.com/willemml/dotfiles.nix.git
synced 2025-04-13 03:37:18 +00:00
Switches to darwin input to my fork
This commit is contained in:
parent
c70f27ee6c
commit
35eae4556d
4 changed files with 7 additions and 92 deletions
11
flake.lock
generated
11
flake.lock
generated
|
@ -7,15 +7,16 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699569089,
|
"lastModified": 1699735666,
|
||||||
"narHash": "sha256-MdOnyXrmMdVU9o7GpcbWKgehoK9L76ihp8rTikPcC1k=",
|
"narHash": "sha256-LxKjDY9Fgjy4bHfvqBl9RwuPSP47hgQA21Ffjtrypaw=",
|
||||||
"owner": "lnl7",
|
"owner": "willemml",
|
||||||
"repo": "nix-darwin",
|
"repo": "nix-darwin",
|
||||||
"rev": "c8f385766ba076a096caa794309c40f89894d88a",
|
"rev": "215f56f908ed88d5660d93e064af439a7fb5a7bf",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "lnl7",
|
"owner": "willemml",
|
||||||
|
"ref": "feat/networking.hosts",
|
||||||
"repo": "nix-darwin",
|
"repo": "nix-darwin",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
darwin.url = "github:lnl7/nix-darwin";
|
darwin.url = "github:willemml/nix-darwin?ref=feat/networking.hosts";
|
||||||
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
emacs-overlay.url = "github:nix-community/emacs-overlay";
|
emacs-overlay.url = "github:nix-community/emacs-overlay";
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
../../common/system.nix
|
../../common/system.nix
|
||||||
../modules/nix/link-inputs.nix
|
../modules/nix/link-inputs.nix
|
||||||
../modules/nix/use-flake-pkgs.nix
|
../modules/nix/use-flake-pkgs.nix
|
||||||
../modules/darwin/hosts.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
# copied from https://github.com/NixOS/nixpkgs/blob/85f1ba3e51676fa8cc604a3d863d729026a6b8eb/nixos/modules/config/networking.nix
|
|
||||||
#
|
|
||||||
# if you get an error saying operation not permitted, run the following command:
|
|
||||||
# sudo chflags nouchg,noschg /etc/hosts
|
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib) types mkBefore;
|
|
||||||
inherit (lib.lists) optional;
|
|
||||||
inherit (lib.options) literalExpression literalMD;
|
|
||||||
inherit (lib.attrsets) attrNames filterAttrs;
|
|
||||||
inherit (lib.strings) concatStringsSep concatMapStrings;
|
|
||||||
cfg = config.networking;
|
|
||||||
in {
|
|
||||||
options = {
|
|
||||||
networking.hosts = lib.mkOption {
|
|
||||||
type = types.attrsOf (types.listOf types.str);
|
|
||||||
example = literalExpression ''
|
|
||||||
{
|
|
||||||
"127.0.0.1" = [ "foo.bar.baz" ];
|
|
||||||
"192.168.0.2" = [ "fileserver.local" "nameserver.local" ];
|
|
||||||
};
|
|
||||||
'';
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
Locally defined maps of hostnames to IP addresses.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.hostFiles = lib.mkOption {
|
|
||||||
type = types.listOf types.path;
|
|
||||||
defaultText = literalMD "Hosts from {option}`networking.hosts` and {option}`networking.extraHosts`";
|
|
||||||
example = literalExpression ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]'';
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
Files that should be concatenated together to form {file}`/etc/hosts`.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.extraHosts = lib.mkOption {
|
|
||||||
type = types.lines;
|
|
||||||
default = "";
|
|
||||||
example = "192.168.0.1 lanlocalhost";
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
Additional verbatim entries to be appended to {file}`/etc/hosts`.
|
|
||||||
For adding hosts from derivation results, use {option}`networking.hostFiles` instead.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
networking.hosts = let
|
|
||||||
hostnames =
|
|
||||||
optional (cfg.hostName != "") cfg.hostName; # Then the hostname (without the domain)
|
|
||||||
in {
|
|
||||||
"127.0.0.1" = hostnames;
|
|
||||||
"::1" = hostnames;
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.hostFiles = let
|
|
||||||
# Note: localhostHosts has to appear first in /etc/hosts so that 127.0.0.1
|
|
||||||
# resolves back to "localhost" (as some applications assume) instead of
|
|
||||||
# the FQDN! By default "networking.hosts" also contains entries for the
|
|
||||||
# FQDN so that e.g. "hostname -f" works correctly.
|
|
||||||
localhostHosts = pkgs.writeText "localhost-hosts" ''
|
|
||||||
127.0.0.1 localhost
|
|
||||||
::1 localhost
|
|
||||||
255.255.255.255 broadcasthost
|
|
||||||
'';
|
|
||||||
stringHosts = let
|
|
||||||
oneToString = set: ip: ip + " " + concatStringsSep " " set.${ip} + "\n";
|
|
||||||
allToString = set: concatMapStrings (oneToString set) (attrNames set);
|
|
||||||
in
|
|
||||||
pkgs.writeText "string-hosts" (allToString (filterAttrs (_: v: v != []) cfg.hosts));
|
|
||||||
extraHosts = pkgs.writeText "extra-hosts" cfg.extraHosts;
|
|
||||||
in
|
|
||||||
mkBefore [localhostHosts stringHosts extraHosts];
|
|
||||||
|
|
||||||
environment.etc.hosts = {
|
|
||||||
copy = true;
|
|
||||||
source = pkgs.concatText "hosts" cfg.hostFiles;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue