Move mcu into full flake-parts module
This commit is contained in:
		
							
								
								
									
										13
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								flake.nix
									
									
									
									
									
								
							@@ -14,6 +14,8 @@
 | 
				
			|||||||
    flake-parts.lib.mkFlake { inherit inputs; } {
 | 
					    flake-parts.lib.mkFlake { inherit inputs; } {
 | 
				
			||||||
      imports = [
 | 
					      imports = [
 | 
				
			||||||
        devenv.flakeModule
 | 
					        devenv.flakeModule
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ./mcu
 | 
				
			||||||
      ];
 | 
					      ];
 | 
				
			||||||
      systems = [ "x86_64-linux" ];
 | 
					      systems = [ "x86_64-linux" ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,14 +28,13 @@
 | 
				
			|||||||
            rootFileContent = builtins.readFile rootdir.outPath;
 | 
					            rootFileContent = builtins.readFile rootdir.outPath;
 | 
				
			||||||
          in
 | 
					          in
 | 
				
			||||||
          pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
 | 
					          pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
 | 
				
			||||||
        withRootdir = f: mkMerge [
 | 
					 | 
				
			||||||
          (import f)
 | 
					 | 
				
			||||||
          { devenv.root = rootdirOpt; }
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
      in
 | 
					      in
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        devenv.shells = {
 | 
					        _module.args.libMy = {
 | 
				
			||||||
          mcu = withRootdir mcu/devenv.nix;
 | 
					          withRootdir = c: mkMerge [
 | 
				
			||||||
 | 
					            c
 | 
				
			||||||
 | 
					            { devenv.root = rootdirOpt; }
 | 
				
			||||||
 | 
					          ];
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										40
									
								
								mcu/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								mcu/default.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  perSystem = { libMy, pkgs, ... }: {
 | 
				
			||||||
 | 
					    devenv.shells.mcu = libMy.withRootdir {
 | 
				
			||||||
 | 
					      packages = with pkgs; [
 | 
				
			||||||
 | 
					        gnumake
 | 
				
			||||||
 | 
					        cmake
 | 
				
			||||||
 | 
					        pkgsCross.arm-embedded.buildPackages.gdb # ARM one is broken
 | 
				
			||||||
 | 
					        gcc-arm-embedded
 | 
				
			||||||
 | 
					        python3
 | 
				
			||||||
 | 
					        picotool
 | 
				
			||||||
 | 
					        openocd-rp2040
 | 
				
			||||||
 | 
					      ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      env = {
 | 
				
			||||||
 | 
					        PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      scripts = {
 | 
				
			||||||
 | 
					        build.exec = ''
 | 
				
			||||||
 | 
					          cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D PICO_STDIO_SEMIHOSTING=1
 | 
				
			||||||
 | 
					          cmake --build build --parallel
 | 
				
			||||||
 | 
					        '';
 | 
				
			||||||
 | 
					        build-rel.exec = ''
 | 
				
			||||||
 | 
					          cmake -S . -B build-release -D CMAKE_BUILD_TYPE=Release
 | 
				
			||||||
 | 
					          cmake --build build-release --parallel
 | 
				
			||||||
 | 
					        '';
 | 
				
			||||||
 | 
					        clean.exec = ''
 | 
				
			||||||
 | 
					          rm -rf build/ build-release/
 | 
				
			||||||
 | 
					        '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ocd.exec = ''
 | 
				
			||||||
 | 
					          openocd -f ${./tigard-swd.cfg} -f target/rp2040.cfg
 | 
				
			||||||
 | 
					        '';
 | 
				
			||||||
 | 
					        gdb.exec = ''
 | 
				
			||||||
 | 
					          arm-none-eabi-gdb -x .gdbinit build/qclk.elf
 | 
				
			||||||
 | 
					        '';
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,36 +0,0 @@
 | 
				
			|||||||
{ pkgs, ... }: {
 | 
					 | 
				
			||||||
  packages = with pkgs; [
 | 
					 | 
				
			||||||
    gnumake
 | 
					 | 
				
			||||||
    cmake
 | 
					 | 
				
			||||||
    pkgsCross.arm-embedded.buildPackages.gdb # ARM one is broken
 | 
					 | 
				
			||||||
    gcc-arm-embedded
 | 
					 | 
				
			||||||
    python3
 | 
					 | 
				
			||||||
    picotool
 | 
					 | 
				
			||||||
    openocd-rp2040
 | 
					 | 
				
			||||||
  ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  env = {
 | 
					 | 
				
			||||||
    PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  scripts = {
 | 
					 | 
				
			||||||
    build.exec = ''
 | 
					 | 
				
			||||||
      cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D PICO_STDIO_SEMIHOSTING=1
 | 
					 | 
				
			||||||
      cmake --build build --parallel
 | 
					 | 
				
			||||||
    '';
 | 
					 | 
				
			||||||
    build-rel.exec = ''
 | 
					 | 
				
			||||||
      cmake -S . -B build-release -D CMAKE_BUILD_TYPE=Release
 | 
					 | 
				
			||||||
      cmake --build build-release --parallel
 | 
					 | 
				
			||||||
    '';
 | 
					 | 
				
			||||||
    clean.exec = ''
 | 
					 | 
				
			||||||
      rm -rf build/ build-release/
 | 
					 | 
				
			||||||
    '';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ocd.exec = ''
 | 
					 | 
				
			||||||
      openocd -f ${./tigard-swd.cfg} -f target/rp2040.cfg
 | 
					 | 
				
			||||||
    '';
 | 
					 | 
				
			||||||
    gdb.exec = ''
 | 
					 | 
				
			||||||
      arm-none-eabi-gdb -x .gdbinit build/qclk.elf
 | 
					 | 
				
			||||||
    '';
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user