separate out container, add shell
This commit is contained in:
parent
7bb0fe54e4
commit
1be0e51b91
4 changed files with 30 additions and 19 deletions
1
VERSION.txt
Normal file
1
VERSION.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0.1.0
|
13
container.nix
Normal file
13
container.nix
Normal 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" ];
|
||||||
|
}
|
28
flake.nix
28
flake.nix
|
@ -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 = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs";
|
nixpkgs.url = "github:nixos/nixpkgs";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
@ -11,8 +14,8 @@
|
||||||
let
|
let
|
||||||
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
|
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
|
||||||
|
|
||||||
# Generate a user-friendly version number for our target.
|
# Generate a user-friendly version number (e.g. "1.2.3-20231027-DIRTY").
|
||||||
version = builtins.substring 0 8 lastModifiedDate;
|
version = "${builtins.readFile ./VERSION.txt}.${builtins.substring 0 8 (self.lastModifiedDate or "19700101")}.${self.shortRev or "DIRTY"}";
|
||||||
|
|
||||||
# System types to support.
|
# System types to support.
|
||||||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||||
|
@ -40,23 +43,12 @@
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in rec {
|
|
||||||
|
|
||||||
|
in rec {
|
||||||
packages = { inherit (pkgs) hello; };
|
packages = { inherit (pkgs) hello; };
|
||||||
packages.default = self.packages.${system}.hello;
|
packages.default = self.packages.${system}.hello;
|
||||||
packages.container = pkgs.dockerTools.buildImage {
|
packages.container = pkgs.callPackage ./container.nix { package = packages.default; };
|
||||||
name = "hello";
|
apps.hello = flake-utils.lib.mkApp { drv = packages.default; };
|
||||||
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; };
|
|
||||||
defaultApp = apps.hello;
|
defaultApp = apps.hello;
|
||||||
# devShells.default = import ./shell.nix { inherit pkgs; };
|
# devShells.default = import ./shell.nix { inherit pkgs; };
|
||||||
}
|
}
|
||||||
|
|
5
shell.nix
Normal file
5
shell.nix
Normal 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; [ ];
|
||||||
|
}
|
Loading…
Reference in a new issue