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

Refactor nix files #99

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ post](https://lewo.abesis.fr/posts/nix-build-container-image/).
```nix
{
inputs.nix2container.url = "github:nlewo/nix2container";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";

outputs = { self, nixpkgs, nix2container }: let
pkgs = import nixpkgs { system = "x86_64-linux"; };
nix2containerPkgs = nix2container.packages.x86_64-linux;
in {
packages.x86_64-linux.hello = nix2containerPkgs.nix2container.buildImage {
outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.nix2container.overlays.default ] ;};
packages.hello = pkgs.nix2container.buildImage {
name = "hello";
config = {
entrypoint = ["${pkgs.hello}/bin/hello"];
};
};
};
in
{ inherit packages; }
)
}
```

Expand Down
3 changes: 1 addition & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,5 @@ let
;
in
{
inherit nix2container-bin skopeo-nix2container;
nix2container = { inherit buildImage buildLayer pullImage pullImageFromManifest; };
inherit nix2container-bin skopeo-nix2container buildImage buildLayer pullImage pullImageFromManifest;
}
32 changes: 16 additions & 16 deletions examples/default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{ pkgs, nix2container }: {
hello = pkgs.callPackage ./hello.nix { inherit nix2container; };
nginx = pkgs.callPackage ./nginx.nix { inherit nix2container; };
bash = pkgs.callPackage ./bash.nix { inherit nix2container; };
basic = pkgs.callPackage ./basic.nix { inherit nix2container; };
nonReproducible = pkgs.callPackage ./non-reproducible.nix { inherit nix2container; };
fromImage = pkgs.callPackage ./from-image.nix { inherit nix2container; };
fromImageManifest = pkgs.callPackage ./from-image-manifest.nix { inherit nix2container; };
getManifest = pkgs.callPackage ./get-manifest.nix { inherit nix2container; };
uwsgi = pkgs.callPackage ./uwsgi { inherit nix2container; };
openbar = pkgs.callPackage ./openbar.nix { inherit nix2container; };
layered = pkgs.callPackage ./layered.nix { inherit nix2container; };
nested = pkgs.callPackage ./nested.nix { inherit nix2container; };
nix = pkgs.callPackage ./nix.nix { inherit nix2container; };
nix-user = pkgs.callPackage ./nix-user.nix { inherit nix2container; };
ownership = pkgs.callPackage ./ownership.nix { inherit nix2container; };
{ pkgs }: {
hello = pkgs.callPackage ./hello.nix { };
nginx = pkgs.callPackage ./nginx.nix { };
bash = pkgs.callPackage ./bash.nix { };
basic = pkgs.callPackage ./basic.nix { };
nonReproducible = pkgs.callPackage ./non-reproducible.nix { };
fromImage = pkgs.callPackage ./from-image.nix { };
fromImageManifest = pkgs.callPackage ./from-image-manifest.nix { };
getManifest = pkgs.callPackage ./get-manifest.nix { };
uwsgi = pkgs.callPackage ./uwsgi { };
openbar = pkgs.callPackage ./openbar.nix { };
layered = pkgs.callPackage ./layered.nix { };
nested = pkgs.callPackage ./nested.nix { };
nix = pkgs.callPackage ./nix.nix { };
nix-user = pkgs.callPackage ./nix-user.nix { };
ownership = pkgs.callPackage ./ownership.nix { };
}
47 changes: 27 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,34 @@
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
nix2container = import ./. {
inherit pkgs system;
};
examples = import ./examples {
inherit pkgs;
inherit (nix2container) nix2container;
};
tests = import ./tests {
inherit pkgs examples;
inherit (nix2container) nix2container;
};
in
rec {
outputs = inputs:
inputs.flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.self.overlays.default ]; };

examples = pkgs.callPackage ./examples { };
tests = pkgs.callPackage ./tests { inherit examples; };

packages = {
inherit (nix2container) nix2container-bin skopeo-nix2container nix2container;
inherit (pkgs.nix2container) nix2container-bin skopeo-nix2container;
inherit examples tests;
default = packages.nix2container-bin;
hello = pkgs.nix2container.buildImage {
name = "hello";
config = {
entrypoint = [ "${pkgs.hello}/bin/hello" ];
};
};
};
defaultPackage = packages.nix2container-bin;
});
in
{
inherit packages;
inherit (pkgs) nix2container;
})
// {
overlays.default = final: prev: {
nix2container = import ./. { system = final.system; pkgs = prev; };
};
};
}
2 changes: 1 addition & 1 deletion tests/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, nix2container, examples }:
{ pkgs, examples, nix2container }:

let
testScript = {
Expand Down