-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
WIP: Nix container images #3
Open
zimbatm
wants to merge
3
commits into
master
Choose a base branch
from
nix-container-images
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
{ nixpkgs ? <nixpkgs> }: | ||
let | ||
nix-container-images = builtins.fetchTarball { | ||
url = "https://github.com/nlewo/nix-container-images/archive/7577da87f7249442b51359e36a0f0493949a14d6.tar.gz"; | ||
sha256 = "0cv3b8gngvb2my1rqs2kxszmwb3s3i72j1wp6jin5f1wjp9km32w"; | ||
}; | ||
in | ||
import nixpkgs { | ||
# docker images run on Linux | ||
system = "x86_64-linux"; | ||
config = {}; | ||
overlays = [ | ||
(import "${nix-container-images}/overlay.nix") | ||
(import ./overlay.nix) | ||
]; | ||
} |
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 |
---|---|---|
@@ -1,56 +1,27 @@ | ||
{ dockerTools | ||
, bash | ||
, cacert | ||
, coreutils | ||
, curl | ||
, gitMinimal | ||
, gnutar | ||
, gzip | ||
, iana-etc | ||
, nix | ||
, xz | ||
}: | ||
{ path, lib, nix }: | ||
let | ||
image = dockerTools.buildImageWithNixDb { | ||
inherit (nix) name; | ||
|
||
contents = [ | ||
./root | ||
coreutils | ||
# add /bin/sh | ||
bash | ||
nix | ||
|
||
# runtime dependencies of nix | ||
cacert | ||
gitMinimal | ||
gnutar | ||
gzip | ||
xz | ||
|
||
# for haskell binaries | ||
iana-etc | ||
]; | ||
|
||
extraCommands = '' | ||
# for /usr/bin/env | ||
mkdir usr | ||
ln -s ../bin usr/bin | ||
channel = | ||
builtins.replaceStrings | ||
["\n"] | ||
[""] | ||
"nixos-${builtins.readFile "${path}/.version"}"; | ||
in | ||
lib.makeImage { | ||
image = { | ||
name = "nix"; | ||
tag = "latest"; | ||
|
||
# make sure /tmp exists | ||
mkdir -m 0777 tmp | ||
''; | ||
run = '' | ||
chmod u+w root | ||
echo 'https://nixos.org/channels/${channel} nixpkgs' > root/.nix-channels | ||
''; | ||
|
||
config = { | ||
Cmd = [ "/bin/bash" ]; | ||
Env = [ | ||
"ENV=/etc/profile.d/nix.sh" | ||
"NIX_PATH=nixpkgs=channel:nixpkgs-unstable" | ||
"PAGER=cat" | ||
"PATH=/usr/bin:/bin" | ||
"SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt" | ||
]; | ||
interactive = true; | ||
}; | ||
}; | ||
in | ||
image // { meta = nix.meta // image.meta; } | ||
environment.systemPackages = [ nix ]; | ||
nix = { | ||
enable = true; | ||
useSandbox = false; | ||
package = nix; | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you intend to keep this up-to-date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now it's manual, but an updater script would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using Niv?
I don't know if it is relevant but we could also use Niv to fetch NixOS releases which seem to be fetched by the CI. Correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah niv could work but the hard part is mostly around CI. make a cron-like job that updates and pushes updates if it works. Mic92 already did something like that for NUR so I might steal that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also have this project for automated updates:
https://github.com/Mic92/iana-etc/blob/master/ci/deploy.sh
Setting up secrets is sometimes a hassle in travis, when you mix up travis.org and travis.com keys.