-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a migrate output to the IHP flake #1762
Conversation
Tested now, with
|
You're missing some steps from the UPGRADE.md (there's been some recent changes to the Makefile boilerplate) |
Fixed the missing from upgrade guide 👍
I got it to run by adding the migrate script like this in the flake.nix. flake.nixosConfigurations."test-server-one" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs // {
environment = "production";
ihp = ihp;
migrate = self.packages.x86_64-linux.migrate;
ihpApp = self.packages.x86_64-linux.default;
};
modules = [
./nixos/configuration.nix
];
}; and then added
Now the error is migrate: Application/Migration: getDirectoryContents:openDirStream: does not exist (No such file or directory) Running |
Does the test app have atleast one migration? Otherwise the |
Ah of course, it didn't. Created now and it run properly 👍 |
It works smoothly, but there is one little issue: Since it cds into the previously built This makes it impossble to run the proper migrations before the nixos-rebuild. Maybe we could take responsibility ourselves for cd-ing into the project directory and that it only provides the |
I'd recommend making this an app instead of an package, so you could directly run it with Could look like this:
I would also recommend letting out the (also as a note, if I'm not mistaken, the migrate script isn't unique to a project but rather a IHP feature, so we could add it directly to the root IHP flake.nix so it could be used independently of having a specific project with |
Yeah, with multiple IHP apps in a server, it would make the most sense to use a nix app like that 👍 |
One consequence of the app approach is that the whole IHP app is being built twice, here and during the rebuild phase, so less efficient (e.g. more disk space/cpu/ram used, and longer build time if not hitting binary cache). With the package appoach, it's instantly present. So for that reason, I'm leaning towards a package without the |
Then let's stick with the package approach for now. I've just removed the |
I'm not sure why it'd be built twice, the app should just use the package that was built before, and why that doesn't happecn with packages. Apps and packages are both just derivations, apps just have a defined execution start point. We could also add both, by the way: a package with just the script, and then (possibly later in another PR) an app, which just call the script from the migration script package. That would be maximally flexible. |
@Eisfunke I'm not sure why myself. Either it has something to do with that it's impure according to nix standards (I think mainly because of I have tried to dig into it, but I'm simply not smart enough to figure this out 😄 Edit: Well, come to think of it, it actually makes sense because the |
flake-module.nix
Outdated
let | ||
projectSrc = pkgs.nix-gitignore.gitignoreSource [] cfg.projectPath; | ||
in | ||
pkgs.writeScriptBin "migrate" '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to prefix with ihp-
to be on the safe side to avoid (probably unlikely) collision with nixpkgs with the same namespace
pkgs.writeScriptBin "migrate" '' | |
pkgs.writeScriptBin "ihp-migrate" '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as this package is build with nix build
it shouldn't cause any collision. I'd prefer to not introduce two names for the same binary, otherwise it will be confusing to other people in the future 👍
Potential fix for #1760
Likely (but untested) this can be used in nixos as:
Then a global
migrate
command would be available