cygwin: add a system builder with a working nix#447520
Draft
corngood wants to merge 119 commits intoNixOS:masterfrom
Draft
cygwin: add a system builder with a working nix#447520corngood wants to merge 119 commits intoNixOS:masterfrom
corngood wants to merge 119 commits intoNixOS:masterfrom
Conversation
32705b6 to
aba3b4f
Compare
Contributor
Author
Anyone have any thoughts on automating the install process? We could quite easily drop an install.cmd/ps1 next to the tarball, and continue to depend on the bsdtar that's included with (some versions?) of windows. We might want to enable case sensitive files before unpacking the tar, so having a script would be nice. However, I don't really like the idea of the installer being two separate loose files. Perhaps there's a good way to embed the tarball in a cmd/ps1 script? Perhaps we could make an installer with mingw? |
Contributor
|
Yeah tar has been included on Windows since 2019. Could make a SFX archive with 7zip |
aba3b4f to
034b06d
Compare
Contributor
Author
Maybe worth a look if it can:
|
14d5b14 to
4d82b24
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This includes:
(2) is very useful for actually testing things. You can easily create a tarball with a desired package set that's fairly simple to install and boot. However, I'm not sure it's suitable for the nixpkgs tree.
It's quite similar to something like nix-darwin, but much more primitive. It currently uses some existing modules from nixos:This was quite helpful to set up /etc/ssl, so https works in nix, and didn't (so far) require any changes to those modules. I know nixos kernel/init system abstraction has been discussed quite a bit, but I haven't checked in on it recently (other than vaguely following launchd support). I'd rather not maintain a separate nix-cygwin tree if possible.This no longer requires a custom nixos eval, and is simply a couple of extra modules you can import: one to build a cygwin system, and one to build a tarball installer.
Building and Installing
On linux (or maybe other systems where nix works), in nixpkgs root:
Make a system config (
cygwin-system.nix) with the cygwin modules imported, e.g.:Run
nix build -f nixos config.system.cygwin.tarball -I nixos-config=./cygwin-system.nixin root to get a tarball.Then on windows
WARNING: currently the install may print an error (about /dev) when run over top of an existing install. This can be treated as success.
WARNING: native windows symlinks may not be created properly on the first install. Running the install twice may be required.
This should boot the system and drop you in a logged in shell.
Using Nix on Cygwin
This branch has many fixes for packages on cygwin, and includes a working native stdenv, so for now you'll have to build using it, or a branch including the same changes.
With flakes you can do this like:
If you build the tarball itself with a flake, you'll benefit from the
lib.nixosSystembehaviour of adding the current nixpkgs to the registry asnixpkgs. You can do that with a standalone flake file, or via an abomination like:In that system you can use:
Keep in mind that building a system like that will require copying nixpkgs to the store whenever it changes, so it'll take a bit longer, and result in a bigger image.
Remote Builder
I have cygwin working as a remote builder, but it's a little bit of a pain at the moment.
I manually created a host key in
~/.ssh/id_ed25519, and an emptysshd_config.I also had to
ln -s /run/current-system/sw/bin/bash /bin/bashfor login to work (there must be a better way to fix that).That should be enough to SSH in.
To work as a trusted builder I had to also generate a store signing key and enable it on cygwin:
And in the linux machine using it as a remote builder:
With this I can do e.g.
nix build -f. --argstr system x86_64-cygwin hellofrom the linux machine.At this point you can also switch to a new system configuration by:
config.system.cygwin.toplevelnix copy --to/nix/var/nix/profiles/system/nix/var/nix/profiles/system/activateQuestions
TODO
/nix-path-registrationat loginerror: killing process [x]: No such processhellobuilds on cygwinnixVersions.gitbuilds on cygwinconfig.system.cygwin.toplevelbuilds on cygwinThings done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.