summaryrefslogtreecommitdiff
path: root/templates/nixos/flake.nix
blob: 2f4f57f605f92a8a5e72b546bbe5b6b827e5a363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  description = "my cool flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    { self, nixpkgs, ... }@inputs:
    let
      inherit (nixpkgs) lib;
      systems = [
        "x86_64-linux"
        "aarch64-linux"
        "x86_64-darwin"
        "aarch64-darwin"
      ];

      forAllSystems = lib.genAttrs systems;
      nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
    in
    {
      nixosConfigurations.myComputer = nixpkgs.lib.nixosSystem {
        modules = [ ./configuration.nix ]; # You should already have this
        specialArgs = {
          # Gives your configuration.nix access to the inputs from above
          inherit inputs;
        };
      };

      devShells = forAllSystems (
        system:
        let
          pkgs = nixpkgsFor.${system};
        in
        {
          default = pkgs.mkShellNoCC {
            packages = [
              pkgs.fzf
              pkgs.just
              # Lets you run `nixfmt` to format all of your files
              self.formatter.${system}
            ];
          };
        }
      );

      # You can also use `nix fmt`
      formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
    };
}