@@ -129,6 +129,10 @@ func TestThinTemplatesExposeSystemAndHomeOverrides(t *testing.T) {
129129 if ! strings .Contains (ConfigurationNix (), "environment.systemPackages" ) {
130130 t .Fatalf ("configuration.nix template must expose system packages\n %s" , ConfigurationNix ())
131131 }
132+ if strings .Contains (ConfigurationNix (), "Edit this configuration file" ) ||
133+ strings .Contains (ConfigurationNix (), "services.desktopManager.plasma6" ) {
134+ t .Fatalf ("configuration.nix template must stay a clean MySetup override\n %s" , ConfigurationNix ())
135+ }
132136 if ! strings .Contains (ConfigurationNix (), "./private" ) {
133137 t .Fatalf ("configuration.nix template must import private defaults\n %s" , ConfigurationNix ())
134138 }
@@ -594,6 +598,50 @@ func TestPrepareThinHostLocalPreservesOverridesLockAndSecrets(t *testing.T) {
594598 }
595599}
596600
601+ func TestPrepareThinHostLocalOverwritesFreshNixOSOverrides (t * testing.T ) {
602+ staging := t .TempDir ()
603+ dest := t .TempDir ()
604+ for path , content := range map [string ]string {
605+ filepath .Join (staging , "configuration.nix" ): ConfigurationNix (),
606+ filepath .Join (staging , "home.nix" ): HomeNix (),
607+ filepath .Join (dest , "hardware-configuration.nix" ): "hardware\n " ,
608+ filepath .Join (dest , "configuration.nix" ): `# Edit this configuration file to define what should be installed on
609+ { pkgs, ... }:
610+
611+ {
612+ imports = [ ./hardware-configuration.nix ];
613+ boot.loader.systemd-boot.enable = true;
614+ services.desktopManager.plasma6.enable = true;
615+ }
616+ ` ,
617+ filepath .Join (dest , "home.nix" ): "{ pkgs, ... }: { home.packages = [ pkgs.kate ]; }\n " ,
618+ } {
619+ if err := os .MkdirAll (filepath .Dir (path ), 0o755 ); err != nil {
620+ t .Fatal (err )
621+ }
622+ if err := os .WriteFile (path , []byte (content ), 0o644 ); err != nil {
623+ t .Fatal (err )
624+ }
625+ }
626+
627+ if err := prepareStagingHostLocal (context .Background (), run.Runner {Stdout : io .Discard , Stderr : io .Discard }, staging , dest , config.Secrets {}, LayoutThin ); err != nil {
628+ t .Fatal (err )
629+ }
630+
631+ for path , want := range map [string ]string {
632+ filepath .Join (staging , "configuration.nix" ): ConfigurationNix (),
633+ filepath .Join (staging , "home.nix" ): HomeNix (),
634+ } {
635+ data , err := os .ReadFile (path )
636+ if err != nil {
637+ t .Fatal (err )
638+ }
639+ if string (data ) != want {
640+ t .Fatalf ("fresh NixOS adoption must keep generated %s, got:\n %s" , filepath .Base (path ), data )
641+ }
642+ }
643+ }
644+
597645func TestPrepareThinHostLocalPreservesPrivateDefault (t * testing.T ) {
598646 staging := t .TempDir ()
599647 dest := t .TempDir ()
@@ -649,9 +697,13 @@ func TestPrepareThinHostLocalReplacesLegacyFullFlake(t *testing.T) {
649697 dest := t .TempDir ()
650698 for path , content := range map [string ]string {
651699 filepath .Join (staging , "flake.nix" ): "generated thin wrapper\n " ,
700+ filepath .Join (staging , "configuration.nix" ): ConfigurationNix (),
701+ filepath .Join (staging , "home.nix" ): HomeNix (),
652702 filepath .Join (dest , "flake.nix" ): "{ description = \" NixOS + Caelestia\" ; }\n " ,
653703 filepath .Join (dest , "flake.lock" ): "legacy full lock\n " ,
654704 filepath .Join (dest , "hardware-configuration.nix" ): "hardware\n " ,
705+ filepath .Join (dest , "configuration.nix" ): "{ pkgs, ... }: { services.desktopManager.plasma6.enable = true; }\n " ,
706+ filepath .Join (dest , "home.nix" ): "{ pkgs, ... }: { home.packages = [ pkgs.kate ]; }\n " ,
655707 filepath .Join (dest , "hosts" , "NixOS" , "host-vars.nix" ): "{ }\n " ,
656708 } {
657709 if err := os .MkdirAll (filepath .Dir (path ), 0o755 ); err != nil {
@@ -676,6 +728,18 @@ func TestPrepareThinHostLocalReplacesLegacyFullFlake(t *testing.T) {
676728 if _ , err := os .Stat (filepath .Join (staging , "flake.lock" )); ! os .IsNotExist (err ) {
677729 t .Fatalf ("legacy full flake.lock should not be copied into thin staging, stat err: %v" , err )
678730 }
731+ for path , want := range map [string ]string {
732+ filepath .Join (staging , "configuration.nix" ): ConfigurationNix (),
733+ filepath .Join (staging , "home.nix" ): HomeNix (),
734+ } {
735+ data , err := os .ReadFile (path )
736+ if err != nil {
737+ t .Fatal (err )
738+ }
739+ if string (data ) != want {
740+ t .Fatalf ("legacy non-thin overrides should not overwrite generated %s, got:\n %s" , filepath .Base (path ), data )
741+ }
742+ }
679743}
680744
681745func TestPrepareThinHostLocalStagesLegacySecretsWhenRootMissing (t * testing.T ) {
0 commit comments