You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tools.nix 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # This module generates nixos-install, nixos-rebuild,
  2. # nixos-generate-config, etc.
  3. { config, lib, pkgs, ... }:
  4. with lib;
  5. let
  6. makeProg = args: pkgs.substituteAll (args // {
  7. dir = "bin";
  8. isExecutable = true;
  9. });
  10. nixos-build-vms = makeProg {
  11. name = "nixos-build-vms";
  12. src = ./nixos-build-vms/nixos-build-vms.sh;
  13. };
  14. nixos-install = makeProg {
  15. name = "nixos-install";
  16. src = ./nixos-install.sh;
  17. nix = config.nix.package.out;
  18. path = makeBinPath [ nixos-enter ];
  19. };
  20. nixos-rebuild =
  21. let fallback = import ./nix-fallback-paths.nix; in
  22. makeProg {
  23. name = "nixos-rebuild";
  24. src = ./nixos-rebuild.sh;
  25. nix = config.nix.package.out;
  26. nix_x86_64_linux = fallback.x86_64-linux;
  27. nix_i686_linux = fallback.i686-linux;
  28. };
  29. nixos-generate-config = makeProg {
  30. name = "nixos-generate-config";
  31. src = ./nixos-generate-config.pl;
  32. path = lib.optionals (lib.elem "btrfs" config.boot.supportedFilesystems) [ pkgs.btrfs-progs ];
  33. perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/${pkgs.perl.libPrefix}";
  34. inherit (config.system.nixos-generate-config) configuration;
  35. };
  36. nixos-option = makeProg {
  37. name = "nixos-option";
  38. src = ./nixos-option.sh;
  39. };
  40. nixos-version = makeProg {
  41. name = "nixos-version";
  42. src = ./nixos-version.sh;
  43. inherit (config.system.nixos) version codeName revision;
  44. };
  45. nixos-enter = makeProg {
  46. name = "nixos-enter";
  47. src = ./nixos-enter.sh;
  48. };
  49. in
  50. {
  51. options.system.nixos-generate-config.configuration = mkOption {
  52. internal = true;
  53. type = types.str;
  54. description = ''
  55. The NixOS module that <literal>nixos-generate-config</literal>
  56. saves to <literal>/etc/nixos/configuration.nix</literal>.
  57. This is an internal option. No backward compatibility is guaranteed.
  58. Use at your own risk!
  59. Note that this string gets spliced into a Perl script. The perl
  60. variable <literal>$bootLoaderConfig</literal> can be used to
  61. splice in the boot loader configuration.
  62. '';
  63. };
  64. config = {
  65. system.nixos-generate-config.configuration = mkDefault ''
  66. # Edit this configuration file to define what should be installed on
  67. # your system. Help is available in the configuration.nix(5) man page
  68. # and in the NixOS manual (accessible by running ‘nixos-help’).
  69. { config, pkgs, ... }:
  70. {
  71. imports =
  72. [ # Include the results of the hardware scan.
  73. ./hardware-configuration.nix
  74. ];
  75. $bootLoaderConfig
  76. # networking.hostName = "nixos"; # Define your hostname.
  77. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
  78. $networkingDhcpConfig
  79. # Configure network proxy if necessary
  80. # networking.proxy.default = "http://user:password\@proxy:port/";
  81. # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
  82. # Select internationalisation properties.
  83. # i18n = {
  84. # consoleFont = "Lat2-Terminus16";
  85. # consoleKeyMap = "us";
  86. # defaultLocale = "en_US.UTF-8";
  87. # };
  88. # Set your time zone.
  89. # time.timeZone = "Europe/Amsterdam";
  90. # List packages installed in system profile. To search, run:
  91. # \$ nix search wget
  92. # environment.systemPackages = with pkgs; [
  93. # wget vim
  94. # ];
  95. # Some programs need SUID wrappers, can be configured further or are
  96. # started in user sessions.
  97. # programs.mtr.enable = true;
  98. # programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
  99. # List services that you want to enable:
  100. # Enable the OpenSSH daemon.
  101. # services.openssh.enable = true;
  102. # Open ports in the firewall.
  103. # networking.firewall.allowedTCPPorts = [ ... ];
  104. # networking.firewall.allowedUDPPorts = [ ... ];
  105. # Or disable the firewall altogether.
  106. # networking.firewall.enable = false;
  107. # Enable CUPS to print documents.
  108. # services.printing.enable = true;
  109. # Enable sound.
  110. # sound.enable = true;
  111. # hardware.pulseaudio.enable = true;
  112. # Enable the X11 windowing system.
  113. # services.xserver.enable = true;
  114. # services.xserver.layout = "us";
  115. # services.xserver.xkbOptions = "eurosign:e";
  116. # Enable touchpad support.
  117. # services.xserver.libinput.enable = true;
  118. # Enable the KDE Desktop Environment.
  119. # services.xserver.displayManager.sddm.enable = true;
  120. # services.xserver.desktopManager.plasma5.enable = true;
  121. # Define a user account. Don't forget to set a password with ‘passwd’.
  122. # users.users.jane = {
  123. # isNormalUser = true;
  124. # extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
  125. # };
  126. # This value determines the NixOS release with which your system is to be
  127. # compatible, in order to avoid breaking some software such as database
  128. # servers. You should change this only after NixOS release notes say you
  129. # should.
  130. system.stateVersion = "${config.system.nixos.release}"; # Did you read the comment?
  131. }
  132. '';
  133. environment.systemPackages =
  134. [ nixos-build-vms
  135. nixos-install
  136. nixos-rebuild
  137. nixos-generate-config
  138. nixos-option
  139. nixos-version
  140. nixos-enter
  141. ];
  142. system.build = {
  143. inherit nixos-install nixos-generate-config nixos-option nixos-rebuild nixos-enter;
  144. };
  145. };
  146. }