Ask HN: Cleanest way to manage Windows OS?
1. No use of dotfiles
I don't like dotfiles because they're difficult to debug and are tend to be bloated, inefficient and complicated. When using home-manager with nix, those are managed by a file named home.nix so it's very clean. It's also error-free as long as options are set appropriately. Maybe my dotfiles management is just terrible, if you know any good way to do this on Windows, please tell me.
2. Everything is configurable from a single file
On NixOS and MacOS with nix-darwin, you can configure basically everything, from package management to system configuration, in a file: configuration.nix
I would like to do the same on Windows. One thing I considered is to make a powershell script that configures everything on execution.
ChatGPT says that I can use something called [Desired State Configuration](https://learn.microsoft.com/en-us/powershell/dsc/getting-started/wingettingstarted?view=dsc-1.1), but as far as I can see the documentation, it's not something I'm looking for. (correct me if I'm wrong)
3. Containered environment for development
On Nix, you can declare everything necessary to build a package so you don't need to install packages on your system by yourself. I don't want to put myself into a dependency hell anymore. But I have an idea for this: using docker. Docker separates developing environment from host's system so there would be no pre-installed dependencies. It would be good and I'm considering learning docker. Next thing I'm considering is to use something like [nx](https://nx.dev/). If you have better ideas, please tell me.
This is pretty much everything I need for my next Windows environment. Every small tips or tricks are welcome.
77 comments
[ 4.6 ms ] story [ 141 ms ] threadInstall WSL2, do everything development under WSL2. It works very well. It even has x server forwarding now, and supports CUDA. No need for docker, simply use VSCode and the Remote SSH extension works natively with WSL2.
Just make sure to get at least 32gb of ram (most windows laptops you can upgrade the ram).
And I think laptops with 32gb of RAM are too expensive for me.
ram is cheap. brand new things are too expensive. check ebay.
I was talking about Thinkpad X13 Gen 4, but yours seems to be better in terms of cost. I don’t really like numerical pads, though.
Having said that my attempt to bear a corporate windows on a corporate laptop with WSL2 was terrible and I ended up installing linux on it and using the online version of office 365. I would run Linux as a host OS and a windows VM for anything specific to windows. There are ways to share filesystems nowadays.
Whenever you wanna develop, just launch VSCode.
Once you are done with school, just install linux in it fully.
That way you contain the inherent mess that a Windows install will eventually devolve into. You also get the ability to snapshot states of your windows install, which makes it possible to mess around a bit and then roll back to a previous state.
You didn't tell what Windows software you want to run, but depending on your needs you could even do a pci-passthrough in this setup.
I do not recommend Ansible as someone else did. You will spend your days fighting a mix of yaml and Jinja. You will end up looking at Python errors because there are no static types. Never again.
Hopefully not relevant for uni work, but still worth mentioning.
If anyone is thinking about using ansible, I would suggest approaching it like a software project.
Define specialised roles, create test playbooks for those individual roles, use these roles to compose more complex playbooks, and offload logic to custom ansible modules that are written in python. This way you catch template problems early and won't wrestle with heavy logic in the template or playbook layer.
Came here to say exactly this, and lo, top comment.
Don't let windows anywhere near you actual hardware.
* MacOS Parallels - Abysmal performance, constant USB timeouts. Virtually useless
* Virtual box on Windows, emulating Windows - Able to detect device, but unable to talk to it.
* Virtual box on Linux emulating Windows - USB does not even detect.
Thinking about it, if you have a very old motherboard the IOMMU layout might have hindered proper hardware separation.
But I doubt OP really need pass-through at all.
The only things I'd suggest as worth it are:
- separate "data" partition on D:, backed up
- back up %APPDATA% and %USERPROFILE%
- learn one of chocolatey or winget
- WSL2 is a Linux VM; "git bash" is surprisingly good at providing a hybrid environment on the Windows filesystem
- otherwise, just let everything dump itself into C:\Program Files and don't worry too much about it. This is what everyone else will be doing.
It used to be beneficial to do regular reinstalls, but those days are long past. I'd expect you to be able to make it through a 3 year course without having a broken installation incident.
(Not clear what tooling you'll be using? Visual Studio? VSCode? What language(s)?)
1 machine at a time.
A configuration allows you to setup a new machine quickly and consistently when one breaks, get stolen, or lost in an inconvenient time.
More importantly, as a developer you want a clean and consistent development environment so that you do not depend on anything accidentally installed on the machine.
In a previous project, development was tied to a specific machine and until I fixed it, the team simply could not migrate to a new machine if anything happened to it.
On top of that you are unlikely to do and need the exact same thing when you will be switching hardware (considering how evolution has slowed down); and new hardware is very often motivated by a change of activity (so the relevant specs and setup te d to change).
Don’t overthink it, just install a plain old windows, use VMs to test stuff and fix things as you go along. Nowadays Windows is stable enough that you are unlikely to need much fixing until you are ready to change the hardware anyway…
Bob is a homage to an old (deceased sadly) family friend, he worked in aerospace in the 1980's and since he knew I was into computers he was kind enough to give me his deprecated kit - so my first PC had a partition named Bob and I've continued it ever since :).
Without Bob I'd most likely be working a near minimum wage job doing something I hated - he gave me access to an IBM PC Compatible when no way could my family have afforded one plus he was a programmer so he gave me books (those paper things we had before the internet).
%APPDATA% lives in %USERPROFILE% as far as I can tell.
> - separate "data" partition on D:, backed up
Since you already back up your %USERPROFILE%, which supposedly lives on C:, what benefit is there in having "data" on a separate partition?
What software do you need to run?
The second risk is if they want to control your setup in some way with some sort of fleet management software. Windows VM inside another OS should be fine with that, but you never know.
Your escape hatch may be a big windows machine 16G+, preferably 24G minimum, and run your linux env in WSL2, android in WSA, or use Hyper-V, etc.
Most probably his UNI just do not want to hear excuses like "but I am running X and it is not working on my Operating System!" and have to deal with supporting people on stuff they don't know / don't want to know.
Forget about configuration as code in pure Windows, been there, it's a waste of your time.
Also I'm not 100% positive but you might need a Windows Pro license to run Docker in Windows (something something virtualization can't recall correctly)
There are many software out there that requires configurations for better experience, so it’s an inevitable problem.
While it's good to have windows ready, keep in mind this is often not strictly true, but rather a strong recommendation. I survived at uni while translating MATLAB exercises to Octave, compiling windows stuff for Wine, etc. If you set up dual booting, you'll likely be able to spend 99% of your time in whatever system you want.
notepad $PROFILE
From there you can configure environment variables, path, etc.
Then follow the advice of being disciplined about separating data and os/programs and just use backups.
Then use wsl2 with nixos as your main dev env and backup/src control your configs.
This setup is really nice and has the benefit of being able to run just about anything.
If you really want to go nuts you could setup a lvl1 hypervisor like proxmox and run All the OSes. I have a machine setup like this and run macos, windows 7-11, various linux. The one you use for video games you can do hardware pass through to get native video performance. Overkill but fun!
Set up WSL2 for all your Nix and fancy configuration needs. It acts and works like a Linux VM, except with Windows 11 you can also run GUI programs. Set up Windows like any normal Windows user would (pay special attention to the disk encryption not being enabled properly if you don't log in with a Microsoft account) and use it as intended.
Windows does not do dotfiles. Well, some Linux programs do, because they don't really care about user experience, but in general everything configuration related will be stored in %appdata% and the registry.
There is no single file configuration for Windows. There are group policy editors that can control a lot of settings, but what you're looking for doesn't exist and existing tools aren't designed for Windows. Trying to make them work will only frustrate you.
As for containers, WSL2 and Docker work fine. They're running on a Linux VM, so they work as well as they do on Linux, barring some minor overhead from networking and file system integrations.
Alternatively, run Windows in a VM if you already have the Macbook. See how far you'll come before you need some kind of hardware acceleration, you may just be able to use a VM for the few Windows only tools you'll actually he using.
Hopefully the latest versions of windows fix these issues. Too many to detail, I can only say I'm on a very locked down, managed version of windows and thankful to have an administrator account for my machine.
Locking Windows down does add some challenges, though. The close integration allows for WSL2 to become a method to bypass some restrictions, so it makes sense that strictly configured MDM solutions will cause issues.
That doesn't seem to apply to OP, though.
Honestly, there's just not a solution you're going to be happy with, coming from Nix. Windows is like categorically maybe the OS most fundamentally unsuited for folks who appreciate sane ways of managing computers.
If you only need it for one piece of software I'd absolutely use wine or a VM.
Tell that to the billion-or-so Windows computers that are straightforwardly managed and remoted-into with Active Directory, SMB, and Remote Desktop. Not to mention group policies, registry files, and PowerShell.
Powershell remoting achieves similar management objectives to ssh but is a very different interface.
So it’s with curiosity that I read this, but I don’t understand what you’re referring to about configuration. Do you mean setting for networking, peripherals and reg edits to get rid of those darn folders for ‘games’ and ‘videos’?
As much as I try to make my own improvements and insurance against downtime, I find I’m spending a lot of time to only discover its best to let Windows do its thing.
Basically everything, including ones that you mentioned. Networking, for example, have these options (link below)
https://search.nixos.org/options?channel=23.11&from=0&size=5...
peripherals are typically managed by “home-manager”
Registry in this context is specific to Windows so I don’t know. Environment variables are configurable.
Dual-booting requires partitioning so I personally don’t really like it.
Not necessarily. As I hinted in the OP, I'm installed on separate drives. My Lenovo tiny has 2x M.2 SSD and 1x 2.5” SSD all in a 7”x7”x1.5” format.
And I don’t think you can avoid partitioning. Windows makes 4 partitions automatically—unless you’re making multiple installations, then it doesn’t duplicate boot (logically problematic) and WinRE
Backups are a good thing, but most kids do their schoolwork in the cloud. Possibly the greatest risk is not software related, but either mechanical damage or theft. And battery death. Don't treat a portable appliance as your most prized possession.
And this is also true of people in general: There doesn't seem to be a correlation between how fussy someone is about keeping their computer just right, and actually getting reliable use out of it. So part of the process is deciding for yourself whether you tend to need more computer management, or less, than the average person.
Maybe the Windows requirement is for running anti-cheating software? There is the chance of you being required to install some bizarre spyware. That kind of stuff can also be highly platform specific, which is usually a sign of it being poorly written.
Back in the day I used "Norton Ghost" to create a full image of a just-installed windows just in case I needed to go back in time. Windows includes a snapshot feature built-in but I did not really trust it. These days you can use a "sysprep" tool [2] to create a similar system snapshot. Make a partition and keep everything you don't want deleted on drive D: or something :-).
--
1: https://www.jetpack.io/devbox
2: like https://www.ntlite.com or https://fogproject.org
You can script windows things with powershell and package managers — which you can test on Windows VMs.
Just make the VMs your primary work machines, and leave the host are unmodified as possible unless absolutely necessary.
Alternatively, you can use a Linux host for VMs.
I'm assuming most people here aren't in the precariat like me. If you are, then get a used Windows laptop, they're even cheaper.
Edit: sorry, missed the portion of the parent comment mentioning used.
WSL2 + VSCode is enough for most of my use cases. Get Power Toys. You can now create a dev drive that has better performance with many small files like in node, if you are not using WSL. Multiple Desktop/Monitor is so much better than Mac. Need to spend couple of hours initially to tune it to my liking, after that it is mostly smooth run. I thought using Choco/WinGet initially but initial installation by going to each site isn't that big a pain. Go with lot of RAM if using Docker.
Any guides on using nix-darwin for system configuration and etc? Ive been using it for a while and Id love to learn more!
https://daiderd.com/nix-darwin/manual/index.html
I keep a git repository with all my dot files in it[1]. This seems to work the best. It has a Windows folder as well, and I copy that out whenever I need to set up Windows.
A lot of people like using WSL but I hate how it hogs on my memory. Hyper-V is a terrible virtualization engine for consumer-grade use cases because it can't thin provision RAM. If I need to use docker, I will spin up a small Linux VM using vagrant[3] with Virtualbox[4] and put Docker on there. Vagrant is an extremely underrated tool in my opinion, particularly in a Windows context.
I use scoop[5] for package management. Typically I will scoop install msys2 and then pin it so that it doesn't get blown away by the next upgrade.
Then I basically do all of my development inside of msys2. I can get most things running in there without virtualization. In my case that means sbcl and roswell for common lisp, senpai for irc, and tmux and nvim for sanity. Msys2 uses the pacman package manager and this is good enough.
All In all, I set up my Windows machine affresh after a while of not using it and it took me about 3 hours. Most of that time was just getting through upgrades though, I felt like it was pretty fast.
1: https://git.sr.ht/~skin/dotfiles
2: https://www.msys2.org/
3: https://www.vagrantup.com/
4: https://www.virtualbox.org/
5: https://scoop.sh/