Skip to content

Commit

Permalink
apt: add apt-mock-packages cmd in system
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Aug 20, 2024
1 parent fd7c4bc commit 6767a8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@bash@/bin/bash
#!/bin/bash

set -euo pipefail

Expand Down
11 changes: 4 additions & 7 deletions modules/apt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ let
cfg = config.programs.apt;
apt = pkgs.callPackage ./apt-patched.nix {};

mock-packages = pkgs.substituteAll {
src = ./mock-packages.sh;
isExecutable = true;

bash = pkgs.bash;
};
apt-mock-packages = pkgs.writeShellScriptBin "apt-mock-packages"
(builtins.readFile ./apt-mock-packages.sh);
in
{
options.programs.apt = {
Expand All @@ -30,6 +26,7 @@ in
environment.systemPackages = [
apt
pkgs.gnupg
apt-mock-packages
];

systemd.services.apt-setup = {
Expand All @@ -55,7 +52,7 @@ in
fi
mkdir -p /var/lib/dpkg
mkdir -p /usr/share/keyrings
${mock-packages} ${escapeShellArgs cfg.fakePackages}
${apt-mock-packages}/bin/apt-mock-packages ${escapeShellArgs cfg.fakePackages}
'';
wantedBy = [ "multi-user.target" "default.target" ];
serviceConfig = {
Expand Down
4 changes: 4 additions & 0 deletions tests/apt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ in
server.succeed("test -e /usr/share/doc/gcc-12-base/copyright")
server.succeed("apt-cache show fake-package")
server.succeed("apt remove fake-package -y")
server.fail("apt-cache show fake-package")
server.fail("apt-cache show fake-package-2")
server.succeed("apt-mock-packages fake-package-2")
server.succeed("apt-cache show fake-package-2")
'';
}

0 comments on commit 6767a8d

Please sign in to comment.