diff options
author | axtloss <3alouchi2006@gmail.com> | 2021-10-05 17:41:40 +0200 |
---|---|---|
committer | axtloss <3alouchi2006@gmail.com> | 2021-10-05 17:41:40 +0200 |
commit | f9d38e687a234de36074590f42fca2e7d442b4a7 (patch) | |
tree | 86308f53e3fbc3603ea18f0d1a200190c5dcf8c8 | |
parent | 11dacd2b73ccfcf0aaa9dc029fb0a8851761b909 (diff) | |
download | nix-tool-f9d38e687a234de36074590f42fca2e7d442b4a7.tar.gz nix-tool-f9d38e687a234de36074590f42fca2e7d442b4a7.tar.bz2 |
add all the files
-rw-r--r-- | configuration.nix | 53 | ||||
-rw-r--r-- | main.rs | 7 |
2 files changed, 60 insertions, 0 deletions
diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..c49e017 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,53 @@ +{ lib, pkgs, config, modulesPath, ... }: + +with lib; +let + defaultUser = "nixos"; + syschdemd = import ./syschdemd.nix { inherit lib pkgs config defaultUser; }; +in +{ + imports = [ + "${modulesPath}/profiles/minimal.nix" + ]; + + # WSL is closer to a container than anything else + boot.isContainer = true; + + environment.etc.hosts.enable = false; + environment.etc."resolv.conf".enable = false; + + networking.dhcpcd.enable = false; + + users.users.${defaultUser} = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + + users.users.root = { + shell = "${syschdemd}/bin/syschdemd"; + # Otherwise WSL fails to login as root with "initgroups failed 5" + extraGroups = [ "root" ]; + }; + + environment.systemPackages = with pkgs; + [ + vim + neofetch + git + ]; + + security.sudo.wheelNeedsPassword = false; + + # Disable systemd units that don't make sense on WSL + systemd.services."serial-getty@ttyS0".enable = false; + systemd.services."serial-getty@hvc0".enable = false; + systemd.services."getty@tty1".enable = false; + systemd.services."autovt@".enable = false; + + systemd.services.firewall.enable = false; + systemd.services.systemd-resolved.enable = false; + systemd.services.systemd-udevd.enable = false; + + # Don't allow emergency mode, because we don't have a console. + systemd.enableEmergencyMode = false; +} @@ -0,0 +1,7 @@ +use std::io::{Read, Write}; +fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> { + let args: std::vec::Vec<String> = std::env::args().collect(); + let mut buffer = String::new(); + std::io::stdin().read_to_string(&mut buffer)?; + write!(std::fs::File::create("newConfiguration.nix")?, "{}", format!("{}environment.systemPackages = with pkgs;\n [\n{}\n{}",std::fs::read_to_string(&args[1]).expect("cant open new configuration").split("environment.systemPackages = with pkgs;\n [").collect::<Vec<&str>>()[0],&buffer.replace(" ", "\n"),std::fs::read_to_string(&args[1]).expect("cant open new configuration").split("environment.systemPackages = with pkgs;\n [").collect::<Vec<&str>>()[1])).expect("cant write into new configuration"); + Ok(()) }
\ No newline at end of file |