-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from AkihiroSuda/dev
Support flake
- Loading branch information
Showing
10 changed files
with
143 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Example: nginx (Flake) | ||
|
||
## Usage | ||
|
||
```bash | ||
export DOCKER_BUILDKIT=1 | ||
docker build -t nginx-nix -f flake.nix . | ||
``` | ||
|
||
``` | ||
docker run -d -p 8080:80 --name nginx-nix nginx-nix | ||
``` | ||
|
||
## Updating dependencies | ||
|
||
```bash | ||
nix flake update --override-input nixpkgs github:NixOS/nixpkgs/master | ||
``` | ||
|
||
You might have to create `~/.config/nix/nix.conf` with the following content: | ||
``` | ||
experimental-features = nix-command flakes | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# syntax = ghcr.io/akihirosuda/buildkit-nix:latest | ||
|
||
{ | ||
outputs = { self, nixpkgs }: | ||
let | ||
pkgs = nixpkgs.legacyPackages.x86_64-linux; | ||
in | ||
with pkgs; { | ||
defaultPackage.x86_64-linux = dockerTools.buildImage { | ||
name = "nginx"; | ||
tag = "nix"; | ||
contents = [ | ||
# fakeNss creates /etc/passwd and /etc/group (https://github.com/NixOS/nixpkgs/blob/e548124f/pkgs/build-support/docker/default.nix#L741-L763) | ||
dockerTools.fakeNss | ||
bash | ||
coreutils | ||
nginx | ||
(writeTextDir "${pkgs.nginx}/html/index.html" '' | ||
<html><body>hello nix</body></html> | ||
'') | ||
]; | ||
# Use extraCommands, not runAsRoot, to avoid dependency on KVM | ||
extraCommands = " | ||
grep -q ^nogroup etc/group || echo nogroup:x:65534: >>etc/group | ||
mkdir -p var/log/nginx var/cache/nginx/client_body | ||
"; | ||
config = { | ||
Cmd = [ "nginx" "-g" "daemon off; error_log /dev/stderr debug;" ]; | ||
ExposedPorts = { | ||
"80/tcp" = { }; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Example: nginx | ||
|
||
## Usage | ||
|
||
```bash | ||
export DOCKER_BUILDKIT=1 | ||
docker build -t nginx-nix -f default.nix . | ||
``` | ||
|
||
``` | ||
docker run -d -p 8080:80 --name nginx-nix nginx-nix | ||
``` | ||
|
||
## Updating dependencies | ||
|
||
```bash | ||
nix-env -i niv | ||
niv update | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters