Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. # To build and use it:
  2. # nix-build docker-nix.nix -A hydraServer && docker load < result && docker run -it nix bash
  3. # In the container:
  4. # nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
  5. # nix-channel --update # and this fails
  6.  
  7.  
  8.  
  9. {pkgs ? import <nixpkgs> {}}:
  10.  
  11. let
  12. nixInit = ''
  13. mkdir tmp
  14. mkdir root
  15. echo "root:x:0:0::/root:/bin/bash" >> etc/passwd
  16. echo "nixbld:x:30000:nixbld1,nixbld2,nixbld3,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld30" >> etc/group
  17. for i in $(seq 1 30); do echo "nixbld$i:x:$((30000 + $i)):30000:::" >> etc/passwd; done \
  18. '';
  19. in
  20. {
  21. hydraServer = pkgs.dockerTools.buildImage rec {
  22. name = "nix";
  23. contents = [
  24. pkgs.coreutils
  25. # debug
  26. pkgs.nix pkgs.bash-completion pkgs.ncurses pkgs.bashInteractive
  27. pkgs.netcat pkgs.curlFull
  28. # pkgs.emacs25-nox
  29. ];
  30. extraCommands = ''
  31. # There is a bug in the docker builder
  32. chmod a+w ../layer
  33. # Should be move to docker build expression. This is used resolv
  34. # dns names from hosts file.
  35. chmod 0750 etc
  36. echo 'hosts: files dns' > etc/nsswitch.conf
  37.  
  38. mkdir -p etc/ssl/certs
  39. ln -s ${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt etc/ssl/certs/ca-certificates.crt
  40. '' + nixInit;
  41. };
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement