{"id":27958412,"url":"https://github.com/determinatesystems/home-manager-example","last_synced_at":"2025-05-07T18:23:27.372Z","repository":{"id":274038458,"uuid":"914396699","full_name":"DeterminateSystems/home-manager-example","owner":"DeterminateSystems","description":"Example Home Manager flake integrated with FlakeHub","archived":false,"fork":false,"pushed_at":"2025-05-02T14:07:24.000Z","size":20,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-02T15:25:08.236Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeterminateSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-09T14:14:42.000Z","updated_at":"2025-04-11T08:12:59.000Z","dependencies_parsed_at":"2025-01-24T14:28:33.883Z","dependency_job_id":"def0bc03-086a-4292-a744-f36e9045817e","html_url":"https://github.com/DeterminateSystems/home-manager-example","commit_stats":null,"previous_names":["determinatesystems/home-manager-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fhome-manager-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fhome-manager-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fhome-manager-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeterminateSystems%2Fhome-manager-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeterminateSystems","download_url":"https://codeload.github.com/DeterminateSystems/home-manager-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252932246,"owners_count":21827259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-07T18:23:26.787Z","updated_at":"2025-05-07T18:23:27.349Z","avatar_url":"https://github.com/DeterminateSystems.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Home Manager Example with FlakeHub Cache\n\nThis repository demonstrates how to build and cache Nix Home Manager configurations using FlakeHub Cache and GitHub CI for both macOS and Ubuntu systems.\nIt showcases a powerful approach to deploying Nix configurations by pre-building and caching fully evaluated closures.\n\n## Overview\n\nThe repository uses [FlakeHub Cache](https://docs.determinate.systems/flakehub/cache) to store pre-built Nix closures of Home Manager configurations.\nThis enables rapid deployment of configurations using the `fh` CLI tool, significantly reducing the time and computational resources needed during deployment.\n\n## How It Works\n\n1. **Configuration Structure**\n   - The repository defines Home Manager configurations for both macOS and Ubuntu in a single flake\n   - Configurations are parameterized by `username` and `hostname`\n   - System-specific packages are conditionally included based on the target platform\n\n2. **Build Process**\n   - GitHub CI builds the configurations for both platforms\n   - The build process fully evaluates and realizes the Nix closures\n   - FlakeHub Cache stores these pre-built closures for later use\n\n3. **Deployment**\n   - Users can quickly deploy configurations using:\n   ```bash\n   # Resolve the pre-built closure from FlakeHub Cache\n   fh resolve \"determinatesystems/home-manager-example/*#homeConfigurations.linuxUsername@linuxHostname\"\n   /nix/store/4rl65vxv427k17nv3fkgqjgpah548b9j-home-manager-generation\n\n   # Apply the configuration\n   fh apply home-manager /nix/store/4rl65vxv427k17nv3fkgqjgpah548b9j-home-manager-generation\n   ```\n\n## Benefits of Pre-built Closures\n\nTraditional Nix deployments require each machine to:\n1. Evaluate the Nix expressions\n2. Realize the closures\n3. Download or build missing dependencies\n\nUsing pre-built closures from FlakeHub Cache offers several advantages:\n- **Faster Deployments**: Skip local evaluation and building\n- **Reduced Resource Usage**: No need for local compilation\n- **Consistent Environments**: Guarantee identical outputs across machines\n- **Lower Bandwidth**: Download only the required closure\n- **CI-Verified**: Configurations are pre-tested in CI\n\n## Repository Structure\n\n```\n.\n├── flake.nix              # Main flake configuration\n├── home-manager/\n│   └── default.nix        # Home Manager configuration\n└── lib/                   # Helper functions\n```\n\n## Key Components\n\n### Flake Inputs\n```nix\ninputs = {\n  determinate.url = \"https://flakehub.com/f/DeterminateSystems/determinate/*\";\n  fh.url = \"https://flakehub.com/f/DeterminateSystems/fh/*\";\n  home-manager.url = \"https://flakehub.com/f/nix-community/home-manager/0.2411.*\";\n  nixpkgs.url = \"https://flakehub.com/f/nixos/nixpkgs/0.2411.*\";\n};\n```\n\n### Configuration Outputs\n\n```nix\nhomeConfigurations = {\n  \"macUsername@macHostname\" = helper.mkHome {\n    username = \"macUsername\";\n    hostname = \"macHostname\";\n    platform = \"darwin-aarch64\";\n  };\n  \"linuxUsername@linuxHostname\" = helper.mkHome {\n    username = \"linuxUsername\";\n    hostname = \"linuxHostname\";\n    platform = \"linux-x86_64\";\n  };\n};\n```\n\n## Beyond Home Manager\n\nThis same technique can be extended to:\n- **NixOS Configurations**: Cache system configurations for faster server deployments\n- **nix-darwin Configurations**: Pre-build macOS system configurations\n- **Development Environments**: Cache development shells and tooling\n\nThe benefits of using FlakeHub Cache become even more pronounced with these larger configurations, as they typically involve more packages and longer build times.\n\n## Getting Started\n\n1. Fork this repository\n2. Update the usernames and hostnames in `flake.nix`\n3. Modify the Home Manager configuration in `home-manager/default.nix`\n4. Push your changes to trigger the CI build\n5. Deploy using `fh resolve` and `fh apply home-manager`\n\n## Further Reading\n\n- [FlakeHub Publishing Guide](https://docs.determinate.systems/flakehub/publishing)\n- [FlakeHub Cache Documentation](https://docs.determinate.systems/flakehub/cache)\n- [FlakeHub Store Paths](https://docs.determinate.systems/flakehub/store-paths)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeterminatesystems%2Fhome-manager-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeterminatesystems%2Fhome-manager-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeterminatesystems%2Fhome-manager-example/lists"}