Skip to content

treewide: deprecate toplevel {build,host,target}Platform#209816

Merged
Artturin merged 2 commits intoNixOS:masterfrom
Artturin:deprecate-top-level-platform-aliases
Jan 9, 2023
Merged

treewide: deprecate toplevel {build,host,target}Platform#209816
Artturin merged 2 commits intoNixOS:masterfrom
Artturin:deprecate-top-level-platform-aliases

Conversation

@Artturin
Copy link
Member

@Artturin Artturin commented Jan 9, 2023

deprecation was attempted in e51f736 #46059

but had to be reverted in 2a6e4ae #46517

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@Artturin Artturin force-pushed the deprecate-top-level-platform-aliases branch 2 times, most recently from 97f4343 to f489615 Compare January 9, 2023 03:22
@Artturin Artturin changed the title top-level: Deprecate top-level {build,host,target}Platform top-level: move top-level {build,host,target}Platform to aliases Jan 9, 2023
deprecation was attempted in e51f736

but had to be reverted in 2a6e4ae
@Artturin Artturin force-pushed the deprecate-top-level-platform-aliases branch from f489615 to ecab3ed Compare January 9, 2023 03:25
@Artturin Artturin changed the title top-level: move top-level {build,host,target}Platform to aliases treewide: remove toplevel {build,host,target}Platform Jan 9, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jan 9, 2023
@github-actions github-actions bot added 6.topic: haskell General-purpose, statically typed, purely functional programming language 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jan 9, 2023
@ofborg ofborg bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jan 9, 2023
@Artturin Artturin force-pushed the deprecate-top-level-platform-aliases branch from 1e0941f to 96f7a94 Compare January 9, 2023 04:06
@github-actions github-actions bot added 6.topic: emacs Text editor 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. labels Jan 9, 2023
@trofi
Copy link
Contributor

trofi commented Jan 9, 2023

2 seemingly minor changes in packages. Should be OK:

$ ./maintainers/scripts/rebuild-amount.sh --print HEAD~2
Estimating rebuild amount by counting changed Hydra jobs (parallel=unset).
      2 x86_64-linux

nixos-install-tools.x86_64-linux                                                                                 /nix/store/kb47yl7zbj569dvxmnwrwaribznix5nb-nixos-install-tools-23.05pre-git
tests.nixos-functions.nixos-test.x86_64-linux                                                                    /nix/store/hvsjj6843vj6dl4l218g0b2liid8ck3d-nixos-system-nixos-test

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do it!

@xaverdh
Copy link
Contributor

xaverdh commented Jan 9, 2023

The nixpkgs.tarball job succeeds for me locally on the pr, lets hope it works on hydra!

@Artturin Artturin marked this pull request as ready for review January 9, 2023 13:51
@Ericson2314
Copy link
Member

Thanks for doing this, @Artturin!

@Artturin Artturin force-pushed the deprecate-top-level-platform-aliases branch from 96f7a94 to 2eeb34c Compare January 9, 2023 19:13
@Artturin
Copy link
Member Author

Artturin commented Jan 9, 2023

2 seemingly minor changes in packages. Should be OK:

$ ./maintainers/scripts/rebuild-amount.sh --print HEAD~2
Estimating rebuild amount by counting changed Hydra jobs (parallel=unset).
      2 x86_64-linux

nixos-install-tools.x86_64-linux                                                                                 /nix/store/kb47yl7zbj569dvxmnwrwaribznix5nb-nixos-install-tools-23.05pre-git
tests.nixos-functions.nixos-test.x86_64-linux                                                                    /nix/store/hvsjj6843vj6dl4l218g0b2liid8ck3d-nixos-system-nixos-test

thats because nixos-install-tools depends on the nixpkgs revision

nixpkgsRevision = config.system.nixos.revision;

@trofi
Copy link
Contributor

trofi commented Jan 9, 2023

nixos-install-tools.x86_64-linux /nix/store

thats because nixos-install-tools depends on the nixpkgs revision

nixpkgsRevision = config.system.nixos.revision;

TIL! Thank you!

@Artturin Artturin merged commit 27c1ec2 into NixOS:master Jan 9, 2023
@Artturin Artturin deleted the deprecate-top-level-platform-aliases branch January 9, 2023 20:15
@Artturin Artturin changed the title treewide: remove toplevel {build,host,target}Platform treewide: deprecate toplevel {build,host,target}Platform Apr 26, 2023
@Artturin
Copy link
Member Author

The attrs in splice.nix weren't removed #350299

Rhys-T added a commit to Rhys-T/nur-packages that referenced this pull request Jul 16, 2025
Didn't realize they were deprecated (NixOS/nixpkgs#209816).
Caused `drl` and `lix-game` to fail when `config.allowAliases = false`.

Fixes #140.
caarlos0 pushed a commit to goreleaser/goreleaser that referenced this pull request Dec 23, 2025
…stem parameter (#6316)

<!-- If applied, this commit will... -->

Fix the deprecation warning that appears on NixOS 24.11+ when using
GoReleaser-generated nix packages:

```
evaluation warning: 'system' has been renamed to/replaced by 'stdenv.hostPlatform.system'
```

The change:
- Removes the `system ? builtins.currentSystem` function parameter
- Derives `system` from `stdenvNoCC.hostPlatform.system` in the let
block
- Reformats function parameters to use consistent Nix style
- Removes the redundant `system = system;` derivation attribute

<!-- Why is this change being made? -->

The old pattern had two issues:

1. **Function parameter**: `system ? builtins.currentSystem` — when
`callPackage` passes arguments, it provides `pkgs.system` which is now a
deprecated alias
2. **Derivation attribute**: `system = system;` — redundant since
`stdenvNoCC.mkDerivation` already sets this via
`stdenv.hostPlatform.system`

This change is safe because:
- The `system` variable remains available in the template for URL/SHA
map lookups
- `stdenvNoCC.hostPlatform.system` is the canonical, non-deprecated way
to access platform information
- This improves cross-compilation support (the original motivation for
the deprecation)
- Tested on NixOS unstable — packages build and run correctly

<!-- Provide links to any relevant tickets, URLs or other resources -->

- [NixOS Discourse: How to fix the 'system' deprecation
warning](https://discourse.nixos.org/t/how-to-fix-evaluation-warning-system-has-been-renamed-to-replaced-by-stdenv-hostplatform-system/72120)
- [Blog: Nix best practices for system
handling](https://isabelroses.com/blog/im-not-mad-im-disappointed/)
- [nixpkgs Issue #27069: Reduce redundant ways to inspect
platforms](NixOS/nixpkgs#27069)
- [nixpkgs PR #209816: Deprecate toplevel platform
attributes](NixOS/nixpkgs#209816)

---

**Testing:**
- [x] All existing nix pipe tests pass locally
- [x] golangci-lint passes with 0 issues
- [x] `task build` succeeds
- [x] Manually tested generated packages (dagger, container-use) on
NixOS unstable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: emacs Text editor 6.topic: haskell General-purpose, statically typed, purely functional programming language 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants