Last active
August 4, 2022 18:10
-
-
Save charles-dyfis-net/7b7c68575fbd5fcb68b9160f6f189bc8 to your computer and use it in GitHub Desktop.
Flake check demonstration
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
{ | |
"nodes": { | |
"nixpkgs": { | |
"locked": { | |
"lastModified": 1659633244, | |
"narHash": "sha256-N+AXQHIyRO5D9T8xrTM+igkqJ90MKsftQJnfW5YNxac=", | |
"owner": "NixOS", | |
"repo": "nixpkgs", | |
"rev": "0b04c001b3c2e5009b688a15ae5903aa2293bc7c", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "NixOS", | |
"repo": "nixpkgs", | |
"type": "github" | |
} | |
}, | |
"root": { | |
"inputs": { | |
"nixpkgs": "nixpkgs" | |
} | |
} | |
}, | |
"root": "root", | |
"version": 7 | |
} |
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
{ | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs"; | |
}; | |
outputs = { self, nixpkgs, ... }: rec { | |
nixosModules = { | |
# with this uncommented, the system build succeeds, but ''nix flake check'' fails | |
testModule = ./module.nix; | |
# with this uncommented, the system build fails. | |
#testModule = import ./module.nix; | |
}; | |
nixosConfigurations = { | |
doubleImportTest = nixpkgs.lib.nixosSystem { | |
system = "x86_64-linux"; | |
modules = [ | |
nixosModules.testModule | |
nixosModules.testModule # in a real-world situation this would typically be an indirect import | |
({pkgs, ...}: { | |
boot.isContainer = true; | |
services.testModuleWorks.enable = true; | |
system.stateVersion = "22.05"; | |
}) | |
]; | |
}; | |
}; | |
}; | |
} |
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
{pkgs, lib, config, ...}: with lib; let cfg = config.services.testModuleWorks; in { | |
options.services.testModuleWorks.enable = mkEnableOption "test module"; | |
config = mkIf cfg.enable { | |
systemd.services.testModuleWorks = { | |
serviceConfig.ExecStart = "${pkgs.coreutils}/bin/sleep infinity"; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment