Skip to content

Commit

Permalink
Automtaically add ipv6 entries to nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandapip1 committed Jan 17, 2025
1 parent 1b19054 commit 7147e45
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
});
in
{
nixosModule = { config, ... }:
nixosModule = { config, pkgs, ... }:
with nixpkgs.lib;
let
cfg = config.networking.stevenBlackHosts;
Expand All @@ -29,9 +29,14 @@
};
config = mkIf cfg.enable {
networking.extraHosts =
builtins.readFile (
"${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts"
);
let
orig = "${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts";
ipv6-merged = pkgs.runCommand "hosts" {} ''
echo "127.0.0.1 localhost" > $out
sort ${orig} | uniq | grep "^0" >> $out
sort ${orig} | uniq | grep "^0" | sed "s/0\.0\.0\.0/::/g" >> $out
'';
in builtins.readFile ipv6-merged;
};
};

Expand Down

0 comments on commit 7147e45

Please sign in to comment.