separate out container, add shell

This commit is contained in:
Greg Burd 2023-09-13 14:24:26 -04:00
parent 7bb0fe54e4
commit 1be0e51b91
No known key found for this signature in database
GPG key ID: 1FC1E7793410DE46
4 changed files with 30 additions and 19 deletions

1
VERSION.txt Normal file
View file

@ -0,0 +1 @@
0.1.0

13
container.nix Normal file
View file

@ -0,0 +1,13 @@
{ pkgs, package }:
pkgs.dockerTools.buildImage {
name = package.pname;
tag = [ "latest" "0.1.0" ]; #package.version
created = "now";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ package ];
pathsToLink = [ "/bin" ];
};
config.Cmd = [ "${package}/bin/hello" ];
}

View file

@ -1,7 +1,10 @@
{
description = "An over-engineered Hello World in C";
description = "A Nix Flake example for ANSI C using GNU Autoconf";
nixConfig = {
bash-prompt = "\\[\\e[34;1m\\]flake.nix ~ \\[\\e[0m\\]";
};
# Nixpkgs / NixOS version to use.
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
@ -11,8 +14,8 @@
let
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
# Generate a user-friendly version number for our target.
version = builtins.substring 0 8 lastModifiedDate;
# Generate a user-friendly version number (e.g. "1.2.3-20231027-DIRTY").
version = "${builtins.readFile ./VERSION.txt}.${builtins.substring 0 8 (self.lastModifiedDate or "19700101")}.${self.shortRev or "DIRTY"}";
# System types to support.
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
@ -40,25 +43,14 @@
})
];
};
in rec {
in rec {
packages = { inherit (pkgs) hello; };
packages.default = self.packages.${system}.hello;
packages.container = pkgs.dockerTools.buildImage {
name = "hello";
tag = "0.1.0";
created = "now";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ packages.default ];
pathsToLink = [ "/bin" ];
};
config.Cmd = [ "${packages.default}/bin/hello" ];
};
apps.hello = flake-utils.lib.mkApp { drv = packages.hello; };
packages.container = pkgs.callPackage ./container.nix { package = packages.default; };
apps.hello = flake-utils.lib.mkApp { drv = packages.default; };
defaultApp = apps.hello;
# devShells.default = import ./shell.nix { inherit pkgs; };
# devShells.default = import ./shell.nix { inherit pkgs; };
}
);
}

5
shell.nix Normal file
View file

@ -0,0 +1,5 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
# nativeBuildInputs is usually what you want -- tools you need to run
#nativeBuildInputs = with pkgs.buildPackages; [ ];
}