- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 815
 
flake.nix: export paths instead of imported files #1046
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
Conversation
| 
           Rebase to master to fix CI.  | 
    
| 
           You need to squash commits...  | 
    
894cef9    to
    db87f5c      
    Compare
  
    db87f5c    to
    cbea1a6      
    Compare
  
    | 
           That was not an enjoyable process. I guess I should not have used GitHub's "sync Branch" button to start with.  | 
    
          
 Learning is hard. But you do it once. I have this alias for git rebase last 2 commits: 
 You learned something new. Great!  | 
    
| 
           I did try exactly that. Merge master into my branch (online, then local pull), and then  Anyway, thanks for your suggestion!  | 
    
          
 You are right.   | 
    
| 
           @mergify queue  | 
    
          
 ✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 3501b9c  | 
    
| 
           I think this PR has broken my importing of  This really confused me until (after some digging) I realised that  This made it easy to switch between AMD only and Nvidia boot specialisations, because disabling Nvidia completely saved some battery. 
 
  | 
    
          
 I've opened an issue to track this: #1052  | 
    
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR NixOS#1046 - Add deprecation assertion for asus-zephyrus-ga402x
| 
           Yeap. Sorry. In addition to 
 this also breaks cases where the export is/was not complying to the  
 BTW: Newer versions of nix would have told you which path it is you got instead of the expected set, which would probably have been useful.  | 
    
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR NixOS#1046 - Add deprecation assertion for lenovo-yoga-7-14ARH7
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR NixOS#1046 - Add deprecation assertion for asus-zephyrus-ga402x
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR NixOS#1046 - Add deprecation assertion for lenovo-yoga-7-14ARH7
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR NixOS#1046 - Add deprecation assertion for lenovo-yoga-7-14ARH7
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR #1046 - Add deprecation assertion for lenovo-yoga-7-14ARH7
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR NixOS#1046 - Add deprecation assertion for asus-zephyrus-ga402x
…tries - Previous attr-set style providing "amdgpu" and "nvidia" is broken by PR #1046 - Add deprecation assertion for asus-zephyrus-ga402x
Description of changes
This lets the
flake.nixexport the modules as paths instead of importing them first. This should work just as well for anyone doingimports = [ inputs.nixos-hardware.nixosModules.foo ], but the key difference is that the module system knows the names of the modules imported that way.This is important for several reasons. At least it let's the module system:
<importing module>:anon-X)disabledModuleswork.I ran into each of those problems at some point or another. There are workarounds like specifying the file path manually instead of using the indirection of the table exported via the
flake.nix, ... but that then also bypasses the abstraction that is supposed to be provided there.Implementation
One could of course remove the 280+
imports inflake.nix, but that is quite a lot of line changes, and the git-blame on this file quite nicely answers the "when was that hardware added?" question (I know that commits can be excluded from the line history, but that is not exactly elegant either).So instead this simply shadows the
importfunction with the id function.An alternative implementation is this:
But that is more verbose and don't see how it is better.
Any implementation is going to break dependents who do some sort of manual transformation of the exported modules (which I have also done in the past), but that is not part of the defined
outputsAPI anyway.Medium to long term I am pretty sure this will avoid weird bugs and breakage.
Things done
nixos-hardwareandimporting it via
<nixos-hardware>or Flake input