Skip to content

Commit

Permalink
refactor tests and rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ibizaman committed Jan 27, 2025
1 parent a40c7ad commit 295d695
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
etcHostsHash=$(shasum -a 256 /etc/hosts | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ]; environment.etc.hosts.knownSha256Hashes = [ \"$etcHostsHash\" ]; environment.etc.hosts.knownSha256Hashes = [ \"$etcHostsHash\" ];/" \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ]; environment.etc.hosts.knownSha256Hashes = [ \"$etcHostsHash\" ];/" \
flake.nix
/usr/bin/sed -i.bak \
's/nixpkgs.hostPlatform = "aarch64-darwin";/nixpkgs.hostPlatform = "'$(nix eval --expr builtins.currentSystem --impure --raw)'";/' \
Expand Down
1 change: 1 addition & 0 deletions modules/networking/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ in

environment.etc.hosts = {
knownSha256Hashes = [
# Comes from MacOS: Darwin 24.1.0 Darwin Kernel Version 24.1.0.
"c7dd0e2ed261ce76d76f852596c5b54026b9a894fa481381ffd399b556c0e2da"
];

Expand Down
17 changes: 5 additions & 12 deletions tests/networking-hosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@
};

test = ''
set -v
echo checking /etc/hosts file >&2
file=${config.out}/etc/hosts
if ! grep '127.0.0.1' $file | head -n1 | grep localhost$; then
exit 1
fi
if ! grep '127.0.0.1' $file | tail -n1 | grep my.super.host$; then
exit 2
fi
if ! grep '::1' $file | grep localhost$; then
exit 3
fi
if ! grep '10.0.0.1' $file | grep my.super.host\ my.other.host$; then
exit 4
fi
grep '127.0.0.1' $file | head -n1 | grep localhost$ || exit 1
grep '127.0.0.1' $file | tail -n1 | grep my.super.host$ || exit 2
grep '::1' $file | grep localhost$ || exit 3
grep '10.0.0.1' $file | grep my.super.host\ my.other.host$ || exit 4
'';
}

0 comments on commit 295d695

Please sign in to comment.